Update app.py
Browse files
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 |
|