Workpam commited on
Commit
29c6c50
·
verified ·
1 Parent(s): 6396546

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
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
- caption = parsed.get(PROMPT, "").strip().capitalize()
 
 
 
 
 
 
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