Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -377,6 +377,20 @@ Dog {i}: Detected with moderate confidence. Here are the top 3 possible breeds:
|
|
| 377 |
else:
|
| 378 |
return final_explanation, annotated_image, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
| 379 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
# Gradio 介面設置
|
| 381 |
with gr.Blocks(css="""
|
| 382 |
.container { max-width: 900px; margin: auto; padding: 20px; }
|
|
|
|
| 377 |
else:
|
| 378 |
return final_explanation, annotated_image, gr.update(visible=False), gr.update(visible=False), gr.update(visible=False)
|
| 379 |
|
| 380 |
+
async def show_details(choice):
|
| 381 |
+
if not choice:
|
| 382 |
+
return "Please select a breed to view details."
|
| 383 |
+
|
| 384 |
+
try:
|
| 385 |
+
if "Dog" in choice:
|
| 386 |
+
_, breed = choice.split(": ", 1)
|
| 387 |
+
else:
|
| 388 |
+
_, breed = choice.split("More about ", 1)
|
| 389 |
+
description = get_dog_description(breed)
|
| 390 |
+
return format_description(description, breed)
|
| 391 |
+
except Exception as e:
|
| 392 |
+
return f"An error occurred while showing details: {e}"
|
| 393 |
+
|
| 394 |
# Gradio 介面設置
|
| 395 |
with gr.Blocks(css="""
|
| 396 |
.container { max-width: 900px; margin: auto; padding: 20px; }
|