File size: 1,386 Bytes
9ba5cad b5d3b7f 9ba5cad b5d3b7f |
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 36 37 38 39 40 41 42 |
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.")
|