DawnC commited on
Commit
9a1b5b2
·
1 Parent(s): e8aca9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -385,11 +385,16 @@ 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)"
 
 
 
 
 
389
  button_id = f"Dog {i+1}: More about {breed}"
390
- dogs_info += f'</li><li><button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button></li>'
391
  buttons.append(button_id)
392
- dogs_info += "</ul>"
393
 
394
  else:
395
  dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
@@ -400,7 +405,8 @@ async def predict(image):
400
  <style>
401
  .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); }}
402
  .dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
403
- .breed-button {{ margin-top: 5px; padding: 5px 10px; background-color: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer; display: inline-block; }}
 
404
  </style>
405
  {dogs_info}
406
  <script>
 
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'<button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
396
  buttons.append(button_id)
397
+ dogs_info += '</div>'
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
  <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-buttons {{ margin-top: 10px; }}
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>