Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -382,13 +382,23 @@ async def predict(image):
|
|
382 |
description = get_dog_description(breed)
|
383 |
dogs_info += format_description_html(description, breed)
|
384 |
|
|
|
385 |
elif combined_confidence >= 0.15:
|
386 |
dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
|
387 |
-
# 確保不會重複顯示品種名稱
|
388 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
389 |
prob = float(prob.replace('%', ''))
|
390 |
dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
|
391 |
dogs_info += "</ul>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
# 在品種的描述下插入對應按鈕
|
394 |
for breed in topk_breeds[:3]:
|
|
|
382 |
description = get_dog_description(breed)
|
383 |
dogs_info += format_description_html(description, breed)
|
384 |
|
385 |
+
# 放入於每個品種敘述區塊中,直接附加 buttons_html
|
386 |
elif combined_confidence >= 0.15:
|
387 |
dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
|
|
|
388 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
389 |
prob = float(prob.replace('%', ''))
|
390 |
dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
|
391 |
dogs_info += "</ul>"
|
392 |
+
|
393 |
+
# Append buttons directly into this dog's section
|
394 |
+
buttons_html = ""
|
395 |
+
for breed in topk_breeds[:3]:
|
396 |
+
button_id = f"Dog {i+1}: More about {breed}"
|
397 |
+
buttons_html += f'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
398 |
+
buttons.append(button_id)
|
399 |
+
|
400 |
+
# 把 buttons_html 放入這個特定狗的區塊
|
401 |
+
dogs_info += buttons_html
|
402 |
|
403 |
# 在品種的描述下插入對應按鈕
|
404 |
for breed in topk_breeds[:3]:
|