apratim24 commited on
Commit
650e4ee
·
verified ·
1 Parent(s): 5332e29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
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
- caption_ids = model.generate(image_features.pixel_values, max_length=50, num_beams=3, temperature=1.0)
 
 
 
 
 
 
 
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]