DawnC commited on
Commit
233c612
ยท
1 Parent(s): 1cd2f29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -448,7 +448,7 @@ async def process_single_dog(image):
448
 
449
 
450
 
451
- # ๅ‡ฝๆ•ธ้ƒจๅˆ†
452
  async def predict(image):
453
  if image is None:
454
  return "Please upload an image to start.", None, gr.update(visible=False, choices=[]), None
@@ -486,11 +486,10 @@ async def predict(image):
486
  dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
487
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
488
  prob = float(prob.replace('%', ''))
489
- # ๅŠ ๅ…ฅๆฏๅ€‹ๅ“็จฎ็š„ๆŒ‰้ˆ•
490
- dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)"
491
  button_id = f"Dog {i+1}: More about {breed}"
492
  buttons.append(button_id) # ็‚บๆฏๅ€‹ๅ“็จฎๅŠ ๅ…ฅๆŒ‰้ˆ•
493
- dogs_info += f'<button value="{button_id}" class="gr-button" style="margin-left: 10px;">Learn More</button></li>'
494
  dogs_info += "</ul>"
495
 
496
  else:
@@ -502,7 +501,6 @@ async def predict(image):
502
  <style>
503
  .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); }}
504
  .dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
505
- .gr-button {{ margin-right: 10px; margin-bottom: 10px; padding: 5px 10px; background-color: #4CAF50; color: white; border: none; border-radius: 3px; cursor: pointer; }}
506
  </style>
507
  {dogs_info}
508
  """
@@ -613,7 +611,5 @@ with gr.Blocks() as iface:
613
 
614
  gr.HTML('For more details on this project and other work, feel free to visit my GitHub <a href="https://github.com/Eric-Chung-0511/Learning-Record/tree/main/Data%20Science%20Projects/Dog_Breed_Classifier">Dog Breed Classifier</a>')
615
 
616
-
617
  if __name__ == "__main__":
618
  iface.launch()
619
-
 
448
 
449
 
450
 
451
+
452
  async def predict(image):
453
  if image is None:
454
  return "Please upload an image to start.", None, gr.update(visible=False, choices=[]), None
 
486
  dogs_info += f"<p>Top 3 possible breeds:</p><ul>"
487
  for j, (breed, prob) in enumerate(zip(topk_breeds[:3], topk_probs_percent[:3])):
488
  prob = float(prob.replace('%', ''))
489
+ # ๅŠ ๅ…ฅๆฏๅ€‹ๅ“็จฎ็š„ Radio ๆŒ‰้ˆ•
 
490
  button_id = f"Dog {i+1}: More about {breed}"
491
  buttons.append(button_id) # ็‚บๆฏๅ€‹ๅ“็จฎๅŠ ๅ…ฅๆŒ‰้ˆ•
492
+ dogs_info += f"<li><strong>{breed}</strong> ({prob:.2f}% confidence)</li>"
493
  dogs_info += "</ul>"
494
 
495
  else:
 
501
  <style>
502
  .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); }}
503
  .dog-info h2 {{ background-color: #f0f0f0; padding: 10px; margin: -15px -15px 15px -15px; border-radius: 5px 5px 0 0; }}
 
504
  </style>
505
  {dogs_info}
506
  """
 
611
 
612
  gr.HTML('For more details on this project and other work, feel free to visit my GitHub <a href="https://github.com/Eric-Chung-0511/Learning-Record/tree/main/Data%20Science%20Projects/Dog_Breed_Classifier">Dog Breed Classifier</a>')
613
 
 
614
  if __name__ == "__main__":
615
  iface.launch()