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