Update app.py
Browse files
app.py
CHANGED
@@ -31,7 +31,16 @@ def caption_and_translate(img, min_len, max_len):
|
|
31 |
# Generate English caption
|
32 |
raw_image = Image.open(img).convert('RGB')
|
33 |
inputs_blip = processor_blip(raw_image, return_tensors="pt")
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
english_caption = processor_blip.decode(out_blip[0], skip_special_tokens=True)
|
36 |
|
37 |
# Translate caption from English to Arabic
|
|
|
31 |
# Generate English caption
|
32 |
raw_image = Image.open(img).convert('RGB')
|
33 |
inputs_blip = processor_blip(raw_image, return_tensors="pt")
|
34 |
+
# Create GenerationConfig with max_length
|
35 |
+
generation_config = GenerationConfig(max_length=max_len)
|
36 |
+
|
37 |
+
out_blip = model_blip.generate(
|
38 |
+
**inputs_blip,
|
39 |
+
min_length=min_len,
|
40 |
+
max_length=max_len,
|
41 |
+
config=generation_config # Pass the generation_config object here
|
42 |
+
)
|
43 |
+
#out_blip = model_blip.generate(**inputs_blip, min_length=5, max_length=50)
|
44 |
english_caption = processor_blip.decode(out_blip[0], skip_special_tokens=True)
|
45 |
|
46 |
# Translate caption from English to Arabic
|