tonyliu404 commited on
Commit
722c532
·
verified ·
1 Parent(s): 03d8b79

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -232,7 +232,7 @@ def classifyImage(input_image):
232
  # Prepare the top 5 predictions with their class names and percentages
233
  top_predictions = [(class_names[i], predictions[i] * 100) for i in top_indices]
234
  for i, (class_name, confidence) in enumerate(top_predictions, 1):
235
- print(f"{i}. Predicted {class_name} with {confidence:.2f}% Confidence")
236
 
237
  return top_predictions
238
 
@@ -385,7 +385,7 @@ with col1:
385
  placeholder = Image.open("dish-placeholder.jpg")
386
  st.image(placeholder, caption="Placeholder Image.", use_container_width=True)
387
  st.header("Top Predictions:")
388
- st.markdown(f"*Donuts*: 98.11%")
389
 
390
  if uploaded_image:
391
  # Open the image
@@ -408,17 +408,16 @@ if recipe_submit and uploaded_image:
408
  fpredictions = ""
409
  class_names = []
410
  confidences = []
411
- MIN_CONFIDENCE = 7 # 7%
412
 
413
  # Show the top predictions with percentages
414
  # st.write("Top Predictions:")
415
  for class_name, confidence in predictions:
416
- fpredictions += f"{class_name}: {confidence:.2f}%,"
417
  class_name = class_name.replace("_", " ")
418
  class_name = class_name.title()
419
  # st.markdown(f"*{class_name}*: {confidence:.2f}%")
420
  class_names.append(class_name)
421
- confidences.append(confidence if confidence > MIN_CONFIDENCE else MIN_CONFIDENCE) #for minimum bar length
422
 
423
  print(fpredictions)
424
 
 
232
  # Prepare the top 5 predictions with their class names and percentages
233
  top_predictions = [(class_names[i], predictions[i] * 100) for i in top_indices]
234
  for i, (class_name, confidence) in enumerate(top_predictions, 1):
235
+ print(f"{i}. Predicted {class_name} with {confidence:.1f}% Confidence")
236
 
237
  return top_predictions
238
 
 
385
  placeholder = Image.open("dish-placeholder.jpg")
386
  st.image(placeholder, caption="Placeholder Image.", use_container_width=True)
387
  st.header("Top Predictions:")
388
+ st.markdown(f"*Donuts*: 98.1%")
389
 
390
  if uploaded_image:
391
  # Open the image
 
408
  fpredictions = ""
409
  class_names = []
410
  confidences = []
 
411
 
412
  # Show the top predictions with percentages
413
  # st.write("Top Predictions:")
414
  for class_name, confidence in predictions:
415
+ fpredictions += f"{class_name}: {confidence:.1f}%,"
416
  class_name = class_name.replace("_", " ")
417
  class_name = class_name.title()
418
  # st.markdown(f"*{class_name}*: {confidence:.2f}%")
419
  class_names.append(class_name)
420
+ confidences.append(confidence)
421
 
422
  print(fpredictions)
423