DawnC commited on
Commit
25af150
ยท
1 Parent(s): dfb8cdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -385,20 +385,25 @@ async def predict(image):
385
  breed = topk_breeds[0]
386
  description = get_dog_description(breed)
387
  dogs_info += format_description_html(description, breed)
 
 
 
 
 
 
388
  elif combined_confidence >= 0.15:
389
  dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
390
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
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>"
@@ -417,6 +422,7 @@ async def predict(image):
417
  """
418
 
419
 
 
420
  return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
421
 
422
  except Exception as e:
 
385
  breed = topk_breeds[0]
386
  description = get_dog_description(breed)
387
  dogs_info += format_description_html(description, breed)
388
+
389
+ # ๅœจ 0.45 ไปฅไธŠๆƒ…ๆณไธ‹็›ดๆŽฅๆ’ๅ…ฅๆŒ‰้ˆ•
390
+ button_id = f"Dog {i+1}: More about {breed}"
391
+ buttons_html += f'<button style="display:inline-block; margin-right:10px;" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
392
+ dogs_info += f'<div class="breed-buttons">{buttons_html}</div>'
393
+
394
  elif combined_confidence >= 0.15:
395
  dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
396
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
397
  prob = float(prob.replace('%', ''))
398
  dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
399
 
400
+ # ็‚บๆฏๅ€‹ๅ“็จฎๆ’ๅ…ฅๆŒ‰้ˆ•
401
  button_id = f"Dog {i+1}: More about {breed}"
402
  buttons_html += f'<button style="display:inline-block; margin-right:10px;" onclick="handle_button_click(\'{button_id}\')">{breed}</button>'
403
 
404
  dogs_info += "</ul>"
405
+ # ๆ’ๅ…ฅๆŒ‰้ˆ•
406
+ dogs_info += f'<div class="breed-buttons">{buttons_html}</div>'
 
407
 
408
  else:
409
  dogs_info += "<p>The image is unclear or the breed is not in the dataset. Please upload a clearer image.</p>"
 
422
  """
423
 
424
 
425
+
426
  return html_output, annotated_image, gr.update(visible=True, choices=buttons), initial_state
427
 
428
  except Exception as e: