Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -541,43 +541,22 @@ async def predict(image):
|
|
| 541 |
description = get_dog_description(breed)
|
| 542 |
html_output += format_description_html(description, breed)
|
| 543 |
|
| 544 |
-
# elif combined_confidence >= 0.15:
|
| 545 |
-
# html_output += f"<p>Top 3 possible breeds:</p><ul>"
|
| 546 |
-
# for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
| 547 |
-
# html_output += f"<li><strong>{breed}</strong> ({prob} confidence)</li>"
|
| 548 |
-
# html_output += "</ul>"
|
| 549 |
-
# html_output += '<div class="breed-buttons">'
|
| 550 |
-
# for breed in topk_breeds[:3]:
|
| 551 |
-
# button_id = f"Dog {i+1}: More about {breed}"
|
| 552 |
-
# html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
| 553 |
-
# buttons.append(button_id)
|
| 554 |
-
# html_output += '</div>'
|
| 555 |
-
|
| 556 |
-
# 當顯示多個品種時,確保不會重複顯示或多餘的內容
|
| 557 |
elif combined_confidence >= 0.15:
|
| 558 |
html_output += f"<p>Top 3 possible breeds:</p><ul>"
|
| 559 |
-
|
| 560 |
-
# 避免多餘的文字,確保每個品種正確顯示
|
| 561 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
| 562 |
html_output += f"<li><strong>{breed}</strong> ({prob} confidence)</li>"
|
| 563 |
-
|
| 564 |
html_output += "</ul>"
|
| 565 |
html_output += '<div class="breed-buttons">'
|
| 566 |
-
|
| 567 |
-
# 使用集合去重,防止重複顯示品種
|
| 568 |
-
unique_breeds = set(topk_breeds[:3])
|
| 569 |
-
for breed in unique_breeds:
|
| 570 |
button_id = f"Dog {i+1}: More about {breed}"
|
| 571 |
html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
| 572 |
buttons.append(button_id)
|
| 573 |
-
|
| 574 |
html_output += '</div>'
|
| 575 |
-
|
| 576 |
|
| 577 |
else:
|
| 578 |
html_output += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
| 579 |
|
| 580 |
-
html_output += '</div>'
|
| 581 |
|
| 582 |
if buttons:
|
| 583 |
html_output += """
|
|
|
|
| 541 |
description = get_dog_description(breed)
|
| 542 |
html_output += format_description_html(description, breed)
|
| 543 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
elif combined_confidence >= 0.15:
|
| 545 |
html_output += f"<p>Top 3 possible breeds:</p><ul>"
|
|
|
|
|
|
|
| 546 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
| 547 |
html_output += f"<li><strong>{breed}</strong> ({prob} confidence)</li>"
|
|
|
|
| 548 |
html_output += "</ul>"
|
| 549 |
html_output += '<div class="breed-buttons">'
|
| 550 |
+
for breed in topk_breeds[:3]:
|
|
|
|
|
|
|
|
|
|
| 551 |
button_id = f"Dog {i+1}: More about {breed}"
|
| 552 |
html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
| 553 |
buttons.append(button_id)
|
|
|
|
| 554 |
html_output += '</div>'
|
|
|
|
| 555 |
|
| 556 |
else:
|
| 557 |
html_output += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
| 558 |
|
| 559 |
+
#html_output += '</div>'
|
| 560 |
|
| 561 |
if buttons:
|
| 562 |
html_output += """
|