import streamlit as st import tensorflow as tf import numpy as np from PIL import Image # Load the model model = tf.keras.models.load_model("brain_stroke_model.keras") # Set title st.title("Brain Stroke Prediction") # Upload image uploaded_file = st.file_uploader("Upload a brain CT scan image", type=["jpg", "jpeg", "png"]) # Prediction function def predict(image): image = image.resize((150, 150)) img_array = np.array(image) / 255.0 img_array = np.expand_dims(img_array, axis=0) pred = model.predict(img_array)[0][0] return pred # Predict button if uploaded_file is not None: image = Image.open(uploaded_file) st.image(image, caption="Uploaded Image", use_column_width=True) prediction = predict(image) if prediction >= 0.5: st.error("❗ Prediction: This person is likely to have a stroke.") else: st.success("✅ Prediction: This person is not likely to have a stroke.")