Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -541,18 +541,33 @@ 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
|
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 |
|
|
|
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 |
elif combined_confidence >= 0.15:
|
557 |
html_output += f"<p>Top 3 possible breeds:</p><ul>"
|
558 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
559 |
html_output += f"<li><strong>{breed}</strong> ({prob} confidence)</li>"
|
560 |
html_output += "</ul>"
|
561 |
+
|
562 |
+
# 確保不會重複加入已經顯示過的品種名
|
563 |
+
unique_breeds = set(topk_breeds[:3]) # 使用集合來去重
|
564 |
html_output += '<div class="breed-buttons">'
|
565 |
+
for breed in unique_breeds:
|
566 |
button_id = f"Dog {i+1}: More about {breed}"
|
567 |
html_output += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
568 |
buttons.append(button_id)
|
569 |
html_output += '</div>'
|
570 |
+
|
571 |
else:
|
572 |
html_output += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
573 |
|