Juho Inkinen commited on
Commit
e94628c
·
unverified ·
1 Parent(s): a90c266

Catch failed subject-indexing requests

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -161,8 +161,12 @@ with gr.Blocks(title="VLM Caption & Annif Demo") as demo:
161
  # Compose Annif project identifier
162
  project_id = f"{project}-{language}"
163
  caption = get_caption(image, prompt)
164
- subjects = get_subjects(caption, project_id)
165
- return caption, subjects
 
 
 
 
166
 
167
  submit_btn.click(
168
  run_app,
 
161
  # Compose Annif project identifier
162
  project_id = f"{project}-{language}"
163
  caption = get_caption(image, prompt)
164
+ try:
165
+ subjects = get_subjects(caption, project_id)
166
+ return caption, subjects
167
+ except gr.Error:
168
+ gr.Warning("Sorry, there was a problem getting subject suggestions.")
169
+ return caption, {}
170
 
171
  submit_btn.click(
172
  run_app,