Spaces:
Running
Running
improved description length
Browse files
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|