Spaces:
Sleeping
Sleeping
Commit
•
7a9a209
1
Parent(s):
948191f
Upload 3 files
Browse files- .gitattributes +1 -0
- Dentella_model (2).ipynb +0 -0
- app.py +60 -0
- dentella.keras +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
dentella.keras filter=lfs diff=lfs merge=lfs -text
|
Dentella_model (2).ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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', # This installs OpenCV without GUI support
|
10 |
+
]
|
11 |
+
|
12 |
+
# Install each library using pip
|
13 |
+
for library in libraries:
|
14 |
+
try:
|
15 |
+
subprocess.check_call(['pip', 'install', library])
|
16 |
+
except subprocess.CalledProcessError as e:
|
17 |
+
print(f"Error installing {library}: {e}")
|
18 |
+
|
19 |
+
import gradio as gr
|
20 |
+
import tensorflow as tf
|
21 |
+
import numpy as np
|
22 |
+
from PIL import Image
|
23 |
+
import io
|
24 |
+
|
25 |
+
# Load the pre-trained TensorFlow model
|
26 |
+
model = tf.keras.models.load_model("dentella.h5")
|
27 |
+
|
28 |
+
# Define the function to predict the teeth health
|
29 |
+
def predict_teeth_health(image):
|
30 |
+
# Convert the PIL image object to a file-like object
|
31 |
+
image_bytes = io.BytesIO()
|
32 |
+
image.save(image_bytes, format="JPEG")
|
33 |
+
|
34 |
+
# Load the image from the file-like object
|
35 |
+
image = tf.keras.preprocessing.image.load_img(image_bytes, target_size=(256, 256))
|
36 |
+
image = tf.keras.preprocessing.image.img_to_array(image)
|
37 |
+
image = np.expand_dims(image, axis=0)
|
38 |
+
|
39 |
+
# Make a prediction
|
40 |
+
prediction = model.predict(image)
|
41 |
+
|
42 |
+
# Get the probability of being 'Good'
|
43 |
+
probability_good = prediction[0][0] # Assuming it's a binary classification
|
44 |
+
|
45 |
+
# Return the predicted class name
|
46 |
+
if probability_good > 0.5:
|
47 |
+
return f"Predicted: Your Teeth are Good And You Don't Need To Visit Doctor"
|
48 |
+
else:
|
49 |
+
return f"Predicted: Your Teeth are Bad And You Need To Visit Doctor"
|
50 |
+
|
51 |
+
# Define the Gradio interface
|
52 |
+
iface = gr.Interface(
|
53 |
+
fn=predict_teeth_health,
|
54 |
+
inputs=gr.Image(type="pil"),
|
55 |
+
outputs="text",
|
56 |
+
title="<h1 style='color: lightgreen; text-align: center;'>Dentella</h1>",
|
57 |
+
)
|
58 |
+
|
59 |
+
# Deploy the Gradio interface using Gradio's hosting service
|
60 |
+
iface.launch(share=True)
|
dentella.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:eeb99586d9a2e58871e3228062f818e5f026376c7499d0bea8a1824ddd12685f
|
3 |
+
size 22385597
|