Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -553,20 +553,26 @@ async def predict(image):
|
|
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>"
|
|
|
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>"
|