Spaces:
Sleeping
Sleeping
| 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}") | |