tonyliu404 commited on
Commit
dd23fdc
·
verified ·
1 Parent(s): 751fa06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -405,9 +405,12 @@ if recipe_submit and uploaded_image:
405
  with col1:
406
  predictions = classifyImage(input_image)
407
  print("Predictions: ", predictions)
 
 
408
  fpredictions = ""
409
  class_names = []
410
  confidences = []
 
411
 
412
  # Show the top predictions with percentages
413
  st.write("Top Predictions:")
@@ -417,7 +420,8 @@ if recipe_submit and uploaded_image:
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
  print(fpredictions)
422
 
423
  #reversing them so graph displays highest predictions at the top
@@ -432,7 +436,6 @@ if recipe_submit and uploaded_image:
432
  bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
433
 
434
  fig.patch.set_alpha(0.2) # Transparent background
435
- fig.patch.set_boxstyle("round,pad=0.1,rounding_size=15") # rounded edges
436
 
437
  # Add labels inside the bars, aligned to the right
438
  for bar in bars:
 
405
  with col1:
406
  predictions = classifyImage(input_image)
407
  print("Predictions: ", predictions)
408
+
409
+ # graph variables
410
  fpredictions = ""
411
  class_names = []
412
  confidences = []
413
+ MIN_CONFIDENCE = 0.05
414
 
415
  # Show the top predictions with percentages
416
  st.write("Top Predictions:")
 
420
  class_name = class_name.title()
421
  st.markdown(f"*{class_name}*: {confidence:.2f}%")
422
  class_names.append(class_name)
423
+ confidences.append(confidence if confidence > MIN_CONFIDENCE else MIN_CONFIDENCE) # minimum length of the bar (5%),
424
+
425
  print(fpredictions)
426
 
427
  #reversing them so graph displays highest predictions at the top
 
436
  bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
437
 
438
  fig.patch.set_alpha(0.2) # Transparent background
 
439
 
440
  # Add labels inside the bars, aligned to the right
441
  for bar in bars: