Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,18 +23,21 @@ def predict_image(image):
|
|
| 23 |
image = tf.keras.preprocessing.image.img_to_array(image)
|
| 24 |
image = np.expand_dims(image, axis=0)
|
| 25 |
|
| 26 |
-
|
| 27 |
prediction = model.predict(image)
|
| 28 |
|
| 29 |
-
# Get the probability of being '
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
-
"prediction": "Your Teeth are Good & You Don't Need To Visit Doctor" if probability_good > 0.5 else "Your Teeth are Bad & You Need To Visit Doctor"
|
| 35 |
-
}
|
| 36 |
-
|
| 37 |
-
return result
|
| 38 |
|
| 39 |
|
| 40 |
# Create the interface
|
|
@@ -49,4 +52,4 @@ iface = gr.Interface(
|
|
| 49 |
|
| 50 |
|
| 51 |
# Launch the interface
|
| 52 |
-
iface.launch(share=True)
|
|
|
|
| 23 |
image = tf.keras.preprocessing.image.img_to_array(image)
|
| 24 |
image = np.expand_dims(image, axis=0)
|
| 25 |
|
| 26 |
+
# Make a prediction
|
| 27 |
prediction = model.predict(image)
|
| 28 |
|
| 29 |
+
# Get the probability of being 'Clean' or 'Carries'
|
| 30 |
+
probabilities = tf.nn.softmax(prediction, axis=-1)
|
| 31 |
+
predicted_class_index = np.argmax(probabilities)
|
| 32 |
+
if predicted_class_index == 0:
|
| 33 |
+
predicted_label = "Clean"
|
| 34 |
+
predicted_probability = probabilities[0][0] * 100 # Convert to percentage
|
| 35 |
+
else:
|
| 36 |
+
predicted_label = "Carries"
|
| 37 |
+
predicted_probability = probabilities[0][1] * 100 # Convert to percentage
|
| 38 |
|
| 39 |
+
# Return the prediction result as a dictionary
|
| 40 |
+
return {"Predicted Label": predicted_label, "Evaluate the teeth": f"{predicted_probability:.2f}%"}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
| 43 |
# Create the interface
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
# Launch the interface
|
| 55 |
+
iface.launch(share=True)
|