app updated
Browse files
app.py
CHANGED
@@ -1,4 +1,41 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import numpy as np
|
4 |
+
import joblib
|
5 |
|
6 |
+
# # Load your trained model (replace 'model.pkl' with your model filename)
|
7 |
+
# model = joblib.load('model.pkl')
|
8 |
+
|
9 |
+
# Function to preprocess the image for prediction
|
10 |
+
def preprocess_image(image):
|
11 |
+
# Convert the image to the format your model expects
|
12 |
+
# This is an example, modify as necessary
|
13 |
+
image = image.resize((224, 224)) # Resize the image
|
14 |
+
image_array = np.array(image) / 255.0 # Normalize the image
|
15 |
+
return image_array.reshape(1, 224, 224, 3) # Adjust shape for model
|
16 |
+
|
17 |
+
# Streamlit UI
|
18 |
+
st.title("Seizure Prediction App")
|
19 |
+
st.write("Upload an image to predict if it indicates a seizure or not.")
|
20 |
+
|
21 |
+
# Image upload
|
22 |
+
uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
|
23 |
+
|
24 |
+
if uploaded_file is not None:
|
25 |
+
# Display the uploaded image
|
26 |
+
image = Image.open(uploaded_file)
|
27 |
+
st.image(image, caption='Uploaded Image', use_column_width=True)
|
28 |
+
|
29 |
+
# Preprocess the image
|
30 |
+
processed_image = preprocess_image(image)
|
31 |
+
|
32 |
+
# Button to predict
|
33 |
+
if st.button("Predict"):
|
34 |
+
# Make prediction
|
35 |
+
prediction = model.predict(processed_image)
|
36 |
+
|
37 |
+
# Display result
|
38 |
+
if prediction[0] == 1:
|
39 |
+
st.success("The model predicts: Seizure detected!")
|
40 |
+
else:
|
41 |
+
st.success("The model predicts: No seizure detected.")
|