Kawthar12h commited on
Commit
40fe0fb
1 Parent(s): 606471a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -10
app.py CHANGED
@@ -31,16 +31,8 @@ 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
- # 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
 
31
  # Generate English caption
32
  raw_image = Image.open(img).convert('RGB')
33
  inputs_blip = processor_blip(raw_image, return_tensors="pt")
34
+
35
+ out_blip = model_blip.generate(**inputs_blip, min_length=50, max_length=500)
 
 
 
 
 
 
 
 
36
  english_caption = processor_blip.decode(out_blip[0], skip_special_tokens=True)
37
 
38
  # Translate caption from English to Arabic