DawnC commited on
Commit
c40d130
·
1 Parent(s): 0aa2a11

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -539,15 +539,13 @@ async def predict(image):
539
  if top1_prob >= 0.45:
540
  breed = topk_breeds[0]
541
  description = get_dog_description(breed)
542
- #html_output += f"<p><strong>{breed}</strong> ({top1_prob:.2%} confidence)</p>"
543
  html_output += format_description_html(description, breed)
544
- button_id = f"Dog {i+1}: More about {breed}"
545
- html_output += f'<div class="breed-buttons"><button class="breed-button" onclick="handle_button_click(\'{button_id}\')">{breed}</button></div>'
546
- buttons.append(button_id)
547
  elif combined_confidence >= 0.15:
548
  html_output += f"<p>Top 3 possible breeds:</p><ul>"
549
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
550
- html_output += f"<li><strong>{breed}</strong> ({prob} confidence)</li>"
551
  html_output += "</ul>"
552
  html_output += '<div class="breed-buttons">'
553
  for breed in topk_breeds[:3]:
@@ -627,10 +625,10 @@ def show_details_html(choice, previous_output, initial_state):
627
 
628
 
629
  def format_description_html(description, breed):
630
- html = "<ul>"
631
  if isinstance(description, dict):
632
  for key, value in description.items():
633
- html += f"<li><strong>{key}:</strong> {value}</li>"
634
  elif isinstance(description, str):
635
  html += f"<li>{description}</li>"
636
  else:
 
539
  if top1_prob >= 0.45:
540
  breed = topk_breeds[0]
541
  description = get_dog_description(breed)
542
+ html_output += f"<p><strong>{breed}</strong> ({top1_prob:.2%} confidence)</p>"
543
  html_output += format_description_html(description, breed)
544
+
 
 
545
  elif combined_confidence >= 0.15:
546
  html_output += f"<p>Top 3 possible breeds:</p><ul>"
547
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
548
+ html_output += f"<li><strong>{breed}</strong> ({prob})</li>"
549
  html_output += "</ul>"
550
  html_output += '<div class="breed-buttons">'
551
  for breed in topk_breeds[:3]:
 
625
 
626
 
627
  def format_description_html(description, breed):
628
+ html = "<ul style='list-style-type: none; padding-left: 0;'>"
629
  if isinstance(description, dict):
630
  for key, value in description.items():
631
+ html += f"<li style='margin-bottom: 10px;'><strong>{key}:</strong> {value}</li>"
632
  elif isinstance(description, str):
633
  html += f"<li>{description}</li>"
634
  else: