Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,26 +17,34 @@ def predict_image(image):
|
|
17 |
# Save the image to a file-like object
|
18 |
image_bytes = io.BytesIO()
|
19 |
image.save(image_bytes, format="JPEG")
|
|
|
20 |
# Load the image from the file-like object
|
21 |
image = tf.keras.preprocessing.image.load_img(image_bytes, target_size=(256, 256))
|
22 |
image = tf.keras.preprocessing.image.img_to_array(image)
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
prediction_dict = {"prediction": predict_label, "confidence": confidence}
|
33 |
-
#return prediction_dict
|
34 |
-
probability_good = outputs[0][0]
|
35 |
result = {
|
36 |
"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"
|
37 |
}
|
38 |
|
39 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
|
42 |
# Create the interface
|
|
|
17 |
# Save the image to a file-like object
|
18 |
image_bytes = io.BytesIO()
|
19 |
image.save(image_bytes, format="JPEG")
|
20 |
+
|
21 |
# Load the image from the file-like object
|
22 |
image = tf.keras.preprocessing.image.load_img(image_bytes, target_size=(256, 256))
|
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 'Good'
|
30 |
+
probability_good = prediction[0][0] # Assuming it's a binary classification
|
31 |
+
|
32 |
+
# Define the prediction result
|
|
|
|
|
|
|
33 |
result = {
|
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 |
+
#predictions = tf.nn.softmax(outputs.logits, axis=-1)
|
39 |
+
#predicted_class = np.argmax(predictions)
|
40 |
+
#if predicted_class == 0:
|
41 |
+
#predict_label = "Clean"
|
42 |
+
#else:
|
43 |
+
#predict_label = "Carries"
|
44 |
+
#confidence = float(np.max(predictions))
|
45 |
+
#prediction_dict = {"prediction": predict_label, "confidence": confidence}
|
46 |
+
#return prediction_dict
|
47 |
+
|
48 |
|
49 |
|
50 |
# Create the interface
|