Update app.py
Browse files
app.py
CHANGED
|
@@ -59,7 +59,13 @@ def generate_alt_text(files, max_new_tokens):
|
|
| 59 |
task=PROMPT,
|
| 60 |
image_size=(img.width, img.height)
|
| 61 |
)
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
captions.append(caption)
|
| 64 |
return "\n\n".join(captions)
|
| 65 |
|
|
|
|
| 59 |
task=PROMPT,
|
| 60 |
image_size=(img.width, img.height)
|
| 61 |
)
|
| 62 |
+
# Handle parsed output which may be nested
|
| 63 |
+
data = parsed.get(PROMPT, "")
|
| 64 |
+
if isinstance(data, dict):
|
| 65 |
+
text = data.get("text", "")
|
| 66 |
+
else:
|
| 67 |
+
text = data
|
| 68 |
+
caption = text.strip().capitalize()
|
| 69 |
captions.append(caption)
|
| 70 |
return "\n\n".join(captions)
|
| 71 |
|