Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -434,7 +434,7 @@ async def predict(image):
|
|
434 |
color = color_list[i % len(color_list)]
|
435 |
draw.rectangle(box, outline=color, width=3)
|
436 |
draw.text((box[0] + 5, box[1] + 5), f"Dog {i+1}", fill=color, font=font)
|
437 |
-
|
438 |
combined_confidence = detection_confidence * top1_prob
|
439 |
html_output += f'<div class="dog-info" style="border-left: 5px solid {color};">'
|
440 |
html_output += f'<h2>Dog {i+1}</h2>'
|
@@ -442,6 +442,7 @@ async def predict(image):
|
|
442 |
if top1_prob >= 0.45:
|
443 |
breed = topk_breeds[0]
|
444 |
description = get_dog_description(breed)
|
|
|
445 |
html_output += format_description_html(description, breed)
|
446 |
button_id = f"Dog {i+1}: More about {breed}"
|
447 |
html_output += f'<div class="breed-buttons"><button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button></div>'
|
@@ -575,7 +576,7 @@ with gr.Blocks() as iface:
|
|
575 |
)
|
576 |
|
577 |
breed_buttons.change(
|
578 |
-
show_details_html,
|
579 |
inputs=[breed_buttons, output, initial_state],
|
580 |
outputs=[output, back_button, initial_state]
|
581 |
)
|
@@ -585,7 +586,7 @@ with gr.Blocks() as iface:
|
|
585 |
inputs=[initial_state],
|
586 |
outputs=[output, output_image, breed_buttons, back_button, initial_state]
|
587 |
)
|
588 |
-
|
589 |
gr.Examples(
|
590 |
examples=['Border_Collie.jpg', 'Golden_Retriever.jpeg', 'Saint_Bernard.jpeg', 'French_Bulldog.jpeg', 'Samoyed.jpg'],
|
591 |
inputs=input_image
|
|
|
434 |
color = color_list[i % len(color_list)]
|
435 |
draw.rectangle(box, outline=color, width=3)
|
436 |
draw.text((box[0] + 5, box[1] + 5), f"Dog {i+1}", fill=color, font=font)
|
437 |
+
|
438 |
combined_confidence = detection_confidence * top1_prob
|
439 |
html_output += f'<div class="dog-info" style="border-left: 5px solid {color};">'
|
440 |
html_output += f'<h2>Dog {i+1}</h2>'
|
|
|
442 |
if top1_prob >= 0.45:
|
443 |
breed = topk_breeds[0]
|
444 |
description = get_dog_description(breed)
|
445 |
+
html_output += f"<p><strong>{breed}</strong> ({top1_prob:.2%} confidence)</p>"
|
446 |
html_output += format_description_html(description, breed)
|
447 |
button_id = f"Dog {i+1}: More about {breed}"
|
448 |
html_output += f'<div class="breed-buttons"><button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button></div>'
|
|
|
576 |
)
|
577 |
|
578 |
breed_buttons.change(
|
579 |
+
show_details_html, # 確保這裡使用 show_details_html
|
580 |
inputs=[breed_buttons, output, initial_state],
|
581 |
outputs=[output, back_button, initial_state]
|
582 |
)
|
|
|
586 |
inputs=[initial_state],
|
587 |
outputs=[output, output_image, breed_buttons, back_button, initial_state]
|
588 |
)
|
589 |
+
|
590 |
gr.Examples(
|
591 |
examples=['Border_Collie.jpg', 'Golden_Retriever.jpeg', 'Saint_Bernard.jpeg', 'French_Bulldog.jpeg', 'Samoyed.jpg'],
|
592 |
inputs=input_image
|