Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import tensorflow as tf
|
| 3 |
+
import numpy as np
|
| 4 |
+
from tensorflow.keras.preprocessing import image
|
| 5 |
+
|
| 6 |
+
# Load the trained model
|
| 7 |
+
model = tf.keras.models.load_model("/content/drive/MyDrive/teeth_classification_model.h5")
|
| 8 |
+
|
| 9 |
+
CLASS_NAMES = ['CaS', 'CoS', 'Gum', 'MC', 'OC', 'OLP', 'OT']
|
| 10 |
+
|
| 11 |
+
st.title("Teeth Disease Classification")
|
| 12 |
+
st.write("Upload an image to classify.")
|
| 13 |
+
|
| 14 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])
|
| 15 |
+
|
| 16 |
+
def preprocess_image(img_path):
|
| 17 |
+
img = image.load_img(img_path, target_size=(224, 224))
|
| 18 |
+
img_array = image.img_to_array(img) / 255.0
|
| 19 |
+
img_array = np.expand_dims(img_array, axis=0)
|
| 20 |
+
return img_array
|
| 21 |
+
|
| 22 |
+
if uploaded_file is not None:
|
| 23 |
+
img_path = "temp.jpg"
|
| 24 |
+
with open(img_path, "wb") as f:
|
| 25 |
+
f.write(uploaded_file.getbuffer())
|
| 26 |
+
|
| 27 |
+
st.image(uploaded_file, caption="Uploaded Image", use_column_width=True)
|
| 28 |
+
|
| 29 |
+
img_array = preprocess_image(img_path)
|
| 30 |
+
|
| 31 |
+
prediction = model.predict(img_array)
|
| 32 |
+
predicted_class = CLASS_NAMES[np.argmax(prediction)]
|
| 33 |
+
|
| 34 |
+
st.write(f"### Prediction: {predicted_class}")
|