Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -385,16 +385,15 @@ async def predict(image):
|
|
385 |
dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
|
386 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
387 |
prob = float(prob.replace('%', ''))
|
388 |
-
dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
|
389 |
-
dogs_info += "</ul>"
|
390 |
-
|
391 |
-
# Add buttons after listing all breeds
|
392 |
-
dogs_info += '<div class="breed-buttons">'
|
393 |
-
for breed in topk_breeds[:3]:
|
394 |
button_id = f"Dog {i+1}: More about {breed}"
|
395 |
-
dogs_info += f
|
|
|
|
|
|
|
|
|
|
|
396 |
buttons.append(button_id)
|
397 |
-
dogs_info +=
|
398 |
|
399 |
else:
|
400 |
dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
@@ -405,8 +404,7 @@ async def predict(image):
|
|
405 |
<style>
|
406 |
.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); }}
|
407 |
.dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
|
408 |
-
.breed-
|
409 |
-
.breed-button {{ margin-right: 10px; padding: 5px 10px; background-color: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer; }}
|
410 |
</style>
|
411 |
{dogs_info}
|
412 |
<script>
|
@@ -437,7 +435,6 @@ async def predict(image):
|
|
437 |
return error_msg, None, gr.update(visible=False, choices=[]), None
|
438 |
|
439 |
|
440 |
-
|
441 |
def show_details_html(choice, previous_output, initial_state):
|
442 |
if not choice:
|
443 |
return previous_output, gr.update(visible=True), initial_state
|
|
|
385 |
dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
|
386 |
for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
|
387 |
prob = float(prob.replace('%', ''))
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
button_id = f"Dog {i+1}: More about {breed}"
|
389 |
+
dogs_info += f"""
|
390 |
+
<li>
|
391 |
+
<strong>{breed}</strong> ({prob:.2f}% confidence)
|
392 |
+
<button class="breed-button" onclick="handle_button_click('{button_id}')">{breed}</button>
|
393 |
+
</li>
|
394 |
+
"""
|
395 |
buttons.append(button_id)
|
396 |
+
dogs_info += "</ul>"
|
397 |
|
398 |
else:
|
399 |
dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
|
|
|
404 |
<style>
|
405 |
.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); }}
|
406 |
.dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
|
407 |
+
.breed-button {{ margin-left: 10px; padding: 2px 5px; background-color: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer; }}
|
|
|
408 |
</style>
|
409 |
{dogs_info}
|
410 |
<script>
|
|
|
435 |
return error_msg, None, gr.update(visible=False, choices=[]), None
|
436 |
|
437 |
|
|
|
438 |
def show_details_html(choice, previous_output, initial_state):
|
439 |
if not choice:
|
440 |
return previous_output, gr.update(visible=True), initial_state
|