Abdallahsadek commited on
Commit
555a76a
·
verified ·
1 Parent(s): f2aac30

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +32 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import tensorflow as tf
4
+ import numpy as np
5
+ from PIL import Image
6
+
7
+ # Load the model
8
+ model = tf.keras.models.load_model("brain_stroke_model.keras")
9
+
10
+ # Set title
11
+ st.title("Brain Stroke Prediction")
12
+
13
+ # Upload image
14
+ uploaded_file = st.file_uploader("Upload a brain CT scan image", type=["jpg", "jpeg", "png"])
15
+
16
+ # Prediction function
17
+ def predict(image):
18
+ image = image.resize((150, 150))
19
+ img_array = np.array(image) / 255.0
20
+ img_array = np.expand_dims(img_array, axis=0)
21
+ pred = model.predict(img_array)[0][0]
22
+ return pred
23
+
24
+ # Predict button
25
+ if uploaded_file is not None:
26
+ image = Image.open(uploaded_file)
27
+ st.image(image, caption="Uploaded Image", use_column_width=True)
28
+ prediction = predict(image)
29
+ if prediction >= 0.5:
30
+ st.error("❗ Prediction: This person is likely to have a stroke.")
31
+ else:
32
+ st.success("✅ Prediction: This person is not likely to have a stroke.")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ tensorflow
3
+ pillow
4
+ numpy