handle low accuracy results
Browse files
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 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
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 |
|