Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,14 @@ def generate_story(image, theme, genre):
|
|
22 |
image_features = feature_extractor(images=image, return_tensors="pt")
|
23 |
|
24 |
# Generate image caption
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# Decode the caption
|
28 |
caption_text = tokenizer.batch_decode(caption_ids, skip_special_tokens=True)[0]
|
|
|
22 |
image_features = feature_extractor(images=image, return_tensors="pt")
|
23 |
|
24 |
# Generate image caption
|
25 |
+
# Generate image caption
|
26 |
+
caption_ids = model.generate(
|
27 |
+
input_ids=image_features.pixel_values,
|
28 |
+
max_length=50,
|
29 |
+
num_beams=3,
|
30 |
+
temperature=1.0,
|
31 |
+
attention_mask=image_features.attention_mask # Pass the attention_mask
|
32 |
+
)
|
33 |
|
34 |
# Decode the caption
|
35 |
caption_text = tokenizer.batch_decode(caption_ids, skip_special_tokens=True)[0]
|