import streamlit as st from PIL import Image import numpy as np import joblib # # Load your trained model (replace 'model.pkl' with your model filename) # model = joblib.load('model.pkl') # Function to preprocess the image for prediction def preprocess_image(image): # Convert the image to the format your model expects # This is an example, modify as necessary image = image.resize((224, 224)) # Resize the image image_array = np.array(image) / 255.0 # Normalize the image return image_array.reshape(1, 224, 224, 3) # Adjust shape for model # Streamlit UI st.title("Seizure Prediction App") st.write("Upload an image to predict if it indicates a seizure or not.") # Image upload uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Display the uploaded image image = Image.open(uploaded_file) st.image(image, caption='Uploaded Image', use_column_width=True) # Preprocess the image processed_image = preprocess_image(image) # Button to predict if st.button("Predict"): # Make prediction prediction = model.predict(processed_image) # Display result if prediction[0] == 1: st.success("The model predicts: Seizure detected!") else: st.success("The model predicts: No seizure detected.")