|
import streamlit as st |
|
from PIL import Image |
|
import numpy as np |
|
import joblib |
|
|
|
|
|
|
|
|
|
|
|
def preprocess_image(image): |
|
|
|
|
|
image = image.resize((224, 224)) |
|
image_array = np.array(image) / 255.0 |
|
return image_array.reshape(1, 224, 224, 3) |
|
|
|
|
|
st.title("Seizure Prediction App") |
|
st.write("Upload an image to predict if it indicates a seizure or not.") |
|
|
|
|
|
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"]) |
|
|
|
if uploaded_file is not None: |
|
|
|
image = Image.open(uploaded_file) |
|
st.image(image, caption='Uploaded Image', use_column_width=True) |
|
|
|
|
|
processed_image = preprocess_image(image) |
|
|
|
|
|
if st.button("Predict"): |
|
|
|
prediction = model.predict(processed_image) |
|
|
|
|
|
if prediction[0] == 1: |
|
st.success("The model predicts: Seizure detected!") |
|
else: |
|
st.success("The model predicts: No seizure detected.") |
|
|