notrey commited on
Commit
38479e1
·
1 Parent(s): c349363

improved description length

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -9,7 +9,14 @@ model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-capt
9
  # Function to generate a descriptive caption
10
  def generate_caption(image):
11
  inputs = processor(image, return_tensors="pt")
12
- out = model.generate(**inputs, max_length=50, num_beams=5, repetition_penalty=1.5)
 
 
 
 
 
 
 
13
  caption = processor.decode(out[0], skip_special_tokens=True)
14
  return caption
15
 
 
9
  # Function to generate a descriptive caption
10
  def generate_caption(image):
11
  inputs = processor(image, return_tensors="pt")
12
+ out = model.generate(
13
+ **inputs,
14
+ max_length=100,
15
+ num_beams=7,
16
+ repetition_penalty=2.0,
17
+ length_penalty=1.2,
18
+ no_repeat_ngram_size=2
19
+ )
20
  caption = processor.decode(out[0], skip_special_tokens=True)
21
  return caption
22