Spaces:
Sleeping
Sleeping
OmarEllethy
commited on
Commit
•
0f3534a
1
Parent(s):
2e0e034
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,13 @@
|
|
1 |
import subprocess
|
2 |
-
import os
|
3 |
|
4 |
-
# Define the list of libraries to install
|
5 |
libraries = [
|
6 |
-
'gradio
|
7 |
-
'tensorflow
|
8 |
-
'numpy
|
9 |
-
'Pillow
|
10 |
-
'opencv-python-headless
|
11 |
-
'
|
12 |
]
|
13 |
|
14 |
# Install each library using pip
|
@@ -24,17 +23,8 @@ import numpy as np
|
|
24 |
from PIL import Image
|
25 |
import io
|
26 |
|
27 |
-
# Load the pre-trained TensorFlow model
|
28 |
-
|
29 |
-
|
30 |
-
# Check if the model file exists
|
31 |
-
if not os.path.exists(model_path):
|
32 |
-
raise FileNotFoundError(f"Model file not found at path: {model_path}")
|
33 |
-
|
34 |
-
try:
|
35 |
-
model = tf.keras.models.load_model(model_path, custom_objects=None, compile=True)
|
36 |
-
except Exception as e:
|
37 |
-
raise IOError(f"Error loading model from {model_path}: {e}")
|
38 |
|
39 |
# Define the function to predict the teeth health
|
40 |
def predict_teeth_health(image):
|
@@ -53,18 +43,19 @@ def predict_teeth_health(image):
|
|
53 |
# Get the probability of being 'Good'
|
54 |
probability_good = prediction[0][0] # Assuming it's a binary classification
|
55 |
|
56 |
-
#
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
|
|
61 |
|
62 |
# Define the Gradio interface
|
63 |
iface = gr.Interface(
|
64 |
fn=predict_teeth_health,
|
65 |
-
inputs=gr.
|
66 |
-
outputs="
|
67 |
-
title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1>",
|
68 |
)
|
69 |
|
70 |
# Deploy the Gradio interface using Gradio's hosting service
|
|
|
1 |
import subprocess
|
|
|
2 |
|
3 |
+
# Define the list of libraries to install
|
4 |
libraries = [
|
5 |
+
'gradio',
|
6 |
+
'tensorflow',
|
7 |
+
'numpy',
|
8 |
+
'Pillow',
|
9 |
+
'opencv-python-headless',
|
10 |
+
'Flask' # Add Flask here
|
11 |
]
|
12 |
|
13 |
# Install each library using pip
|
|
|
23 |
from PIL import Image
|
24 |
import io
|
25 |
|
26 |
+
# Load the pre-trained TensorFlow model
|
27 |
+
model = tf.keras.models.load_model("imageclassifier.h5")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
# Define the function to predict the teeth health
|
30 |
def predict_teeth_health(image):
|
|
|
43 |
# Get the probability of being 'Good'
|
44 |
probability_good = prediction[0][0] # Assuming it's a binary classification
|
45 |
|
46 |
+
# Define the prediction result
|
47 |
+
result = {
|
48 |
+
"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"
|
49 |
+
}
|
50 |
+
|
51 |
+
return result
|
52 |
|
53 |
# Define the Gradio interface
|
54 |
iface = gr.Interface(
|
55 |
fn=predict_teeth_health,
|
56 |
+
inputs=gr.Image(type="pil"),
|
57 |
+
outputs="json",
|
58 |
+
title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1><p style='text-align: center; color: skyblue; font-size: 30px;'>Please Enter Your Teeth Here...</p>",
|
59 |
)
|
60 |
|
61 |
# Deploy the Gradio interface using Gradio's hosting service
|