alexnasa commited on
Commit
3edd428
Β·
verified Β·
1 Parent(s): ff639cc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -238,6 +238,17 @@ def generate_image(
238
  captions = [caption_1, caption_2, caption_3]
239
  idips_checkboxes = [use_id_1, use_id_2, use_id_3]
240
 
 
 
 
 
 
 
 
 
 
 
 
241
  print(f"Length of images: {len(images)}")
242
  print(f"Length of captions: {len(captions)}")
243
 
 
238
  captions = [caption_1, caption_2, caption_3]
239
  idips_checkboxes = [use_id_1, use_id_2, use_id_3]
240
 
241
+ # β€”β€”β€” Fallback to VLM caption if any caption is empty β€”β€”β€”
242
+ for idx, (img, cap) in enumerate(zip(images, captions)):
243
+ if img is not None:
244
+ if not cap or cap.strip() == "":
245
+ try:
246
+ captions[idx] = vlm_img_caption(img)
247
+ except Exception as e:
248
+ # if captioning fails, leave it empty or log as you wish
249
+ print(f"Failed to generate caption for image {idx}: {e}")
250
+ # β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”
251
+
252
  print(f"Length of images: {len(images)}")
253
  print(f"Length of captions: {len(captions)}")
254