etahamad commited on
Commit
39f4ad3
1 Parent(s): 04ddb18

handle low accuracy results

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -88,8 +88,12 @@ def classify_and_visualize(image):
88
  predicted_class = tf.argmax(prediction[0], axis=-1)
89
  confidence = np.max(prediction[0])
90
 
91
- class_name = class_names[predicted_class.numpy()]
92
- bounded_image = edge_and_cut(image, 200, 400)
 
 
 
 
93
 
94
  return class_name, confidence, bounded_image
95
 
 
88
  predicted_class = tf.argmax(prediction[0], axis=-1)
89
  confidence = np.max(prediction[0])
90
 
91
+ if confidence < 0.60:
92
+ class_name = "The image you uploaded might not be in the dataset. Try making your leaf background white."
93
+ bounded_image = image
94
+ else:
95
+ class_name = class_names[predicted_class.numpy()]
96
+ bounded_image = edge_and_cut(image, 200, 400)
97
 
98
  return class_name, confidence, bounded_image
99