DawnC commited on
Commit
4fd0690
·
verified ·
1 Parent(s): 619efc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -410,17 +410,15 @@ with gr.Blocks(css="""
410
  breed_buttons = gr.Radio([], label="Select breed for more details", visible=False)
411
  breed_details = gr.Markdown(label="Breed Details")
412
 
413
- def handle_error(error):
414
- return str(error), None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
 
 
 
415
 
416
  input_image.change(
417
- predict,
418
  inputs=input_image,
419
- outputs=[output, output_image, breed_buttons, breed_details],
420
- api_name="predict"
421
- ).catch(
422
- fn=handle_error,
423
- inputs=None,
424
  outputs=[output, output_image, breed_buttons, breed_details]
425
  )
426
 
 
410
  breed_buttons = gr.Radio([], label="Select breed for more details", visible=False)
411
  breed_details = gr.Markdown(label="Breed Details")
412
 
413
+ async def safe_predict(image):
414
+ try:
415
+ return await predict(image)
416
+ except Exception as e:
417
+ return str(e), None, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
418
 
419
  input_image.change(
420
+ safe_predict,
421
  inputs=input_image,
 
 
 
 
 
422
  outputs=[output, output_image, breed_buttons, breed_details]
423
  )
424