Update app.py
Browse files
app.py
CHANGED
@@ -244,11 +244,24 @@ def generate_image(
|
|
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 |
|
|
|
244 |
if not cap or cap.strip() == "":
|
245 |
try:
|
246 |
captions[idx] = vlm_img_caption(img)
|
247 |
+
|
248 |
+
gr.Info(f"ENT{idx+1} Prompt Missing. Auto Generating Caption")
|
249 |
except Exception as e:
|
250 |
# if captioning fails, leave it empty or log as you wish
|
251 |
print(f"Failed to generate caption for image {idx}: {e}")
|
252 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
253 |
|
254 |
+
# βββ Build a default prompt if none was provided βββ
|
255 |
+
if not prompt or prompt.strip() == "":
|
256 |
+
|
257 |
+
# collect ENT1, ENT2, β¦ for every non-None image
|
258 |
+
ents = [f"ENT{i+1}" for i, img in enumerate(images) if img is not None]
|
259 |
+
# join them with spaces (or β and β if you prefer)
|
260 |
+
prompt = " and ".join(ents)
|
261 |
+
# e.g. prompt becomes "ENT1 ENT2" or "ENT1 ENT2 ENT3"
|
262 |
+
gr.Info(f"Prompt Not Provided, Defaulting to {prompt}")
|
263 |
+
# ββββββββββββββββββββββββββββββββββββββββ
|
264 |
+
|
265 |
print(f"Length of images: {len(images)}")
|
266 |
print(f"Length of captions: {len(captions)}")
|
267 |
|