Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import numpy as np | |
| from tensorflow.keras.models import load_model | |
| from tensorflow.keras.preprocessing import image | |
| from PIL import Image | |
| # Load the updated Keras model | |
| model = load_model("clean_model.keras") | |
| st.title("Disease Prediction App") | |
| st.write("Upload an image and get prediction") | |
| # Upload image | |
| uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) | |
| if uploaded_file is not None: | |
| # Display the uploaded image | |
| img = Image.open(uploaded_file) | |
| st.image(img, caption="Uploaded Image", use_column_width=True) | |
| # Preprocess image | |
| img = img.resize((64, 64)) # Replace with your model's expected input size | |
| img_array = image.img_to_array(img) | |
| img_array = np.expand_dims(img_array, axis=0) / 255.0 | |
| # Predict | |
| prediction = model.predict(img_array) | |
| # Result | |
| if prediction[0][0] > 0.5: | |
| st.write("🔴 Disease Detected") | |
| else: | |
| st.write("🟢 No Disease Detected") | |