Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -391,33 +391,32 @@ async def predict(image):
|
|
391 |
prob = float(prob.replace('%', ''))
|
392 |
dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
|
393 |
|
394 |
-
#
|
395 |
button_id = f"Dog {i+1}: More about {breed}"
|
396 |
-
buttons_html += f'<button
|
397 |
-
|
398 |
-
|
399 |
dogs_info += "</ul>"
|
400 |
|
401 |
-
#
|
402 |
-
dogs_info +=
|
403 |
|
404 |
else:
|
405 |
dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
406 |
|
407 |
dogs_info += '</div>' # ็ตๆ็ถๅ็็่ณ่จๅๅก
|
408 |
-
|
409 |
-
|
410 |
-
# ็ขบไฟ `html_output` ๆ่ณฆๅผ
|
411 |
html_output = f"""
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
"""
|
420 |
|
|
|
421 |
return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
|
422 |
|
423 |
except Exception as e:
|
|
|
391 |
prob = float(prob.replace('%', ''))
|
392 |
dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
|
393 |
|
394 |
+
# ็ๆ่ๆฏๅๅ็จฎๅฐๆ็ๆ้๏ผ้ๆฌกไธไฝฟ็จ Gradio ็ๆ้็ๆๆนๅผ๏ผ่ๆฏ็ดๆฅ็จ HTML ไพๅตๅ
ฅๆ้
|
395 |
button_id = f"Dog {i+1}: More about {breed}"
|
396 |
+
buttons_html += f'<button style="display:inline-block; margin-right:10px;" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
|
397 |
+
|
|
|
398 |
dogs_info += "</ul>"
|
399 |
|
400 |
+
# ๅฐๆ้็ดๆฅๅตๅ
ฅๆ่ฟฐๅ
ง
|
401 |
+
dogs_info += buttons_html
|
402 |
|
403 |
else:
|
404 |
dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
405 |
|
406 |
dogs_info += '</div>' # ็ตๆ็ถๅ็็่ณ่จๅๅก
|
407 |
+
|
408 |
+
# ๆๅพ็ๆๅฎๆด็ HTML ่ผธๅบ
|
|
|
409 |
html_output = f"""
|
410 |
+
<style>
|
411 |
+
.dog-info {{ border: 1px solid #ddd; margin-bottom: 20px; padding: 15px; border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }}
|
412 |
+
.dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
|
413 |
+
.breed-buttons {{ margin-top: 10px; }}
|
414 |
+
.breed-button {{ margin-right: 10px; margin-bottom: 10px; padding: 5px 10px; background-color: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer; }}
|
415 |
+
</style>
|
416 |
+
{dogs_info}
|
417 |
"""
|
418 |
|
419 |
+
|
420 |
return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
|
421 |
|
422 |
except Exception as e:
|