keshavsingh2003 commited on
Commit
7728c0a
·
verified ·
1 Parent(s): 000dc7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -1,30 +1,33 @@
1
  import streamlit as st
2
  import numpy as np
3
- from keras.models import load_model
4
- from keras.preprocessing import image
5
  from PIL import Image
6
 
7
- # Load model (make sure brain_tumor_model.h5 is in same folder)
8
- model = load_model("brain_tumor_model.h5")
9
 
10
- # Set title
11
- st.title("🧠 Brain Tumor Detection using CNN")
12
 
13
- # File uploader
14
- uploaded_file = st.file_uploader("Upload an MRI scan image", type=["jpg", "jpeg", "png"])
15
 
16
  if uploaded_file is not None:
17
- # Show image
18
  img = Image.open(uploaded_file)
19
  st.image(img, caption="Uploaded Image", use_column_width=True)
20
 
21
- # Preprocessing
22
- img = img.resize((64, 64)) # adjust size to match model input
23
  img_array = image.img_to_array(img)
24
- img_array = np.expand_dims(img_array, axis=0) / 255.0 # Normalize
25
 
26
  # Predict
27
  prediction = model.predict(img_array)
28
- result = "🧠 Brain Tumor Detected" if prediction[0][0] > 0.5 else "✅ No Brain Tumor Detected"
29
 
30
- st.markdown(f"### Result: {result}")
 
 
 
 
 
1
  import streamlit as st
2
  import numpy as np
3
+ from tensorflow.keras.models import load_model
4
+ from tensorflow.keras.preprocessing import image
5
  from PIL import Image
6
 
7
+ # Load the updated Keras model
8
+ model = load_model("clean_model.keras")
9
 
10
+ st.title("Disease Prediction App")
11
+ st.write("Upload an image and get prediction")
12
 
13
+ # Upload image
14
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
15
 
16
  if uploaded_file is not None:
17
+ # Display the uploaded image
18
  img = Image.open(uploaded_file)
19
  st.image(img, caption="Uploaded Image", use_column_width=True)
20
 
21
+ # Preprocess image
22
+ img = img.resize((64, 64)) # Replace with your model's expected input size
23
  img_array = image.img_to_array(img)
24
+ img_array = np.expand_dims(img_array, axis=0) / 255.0
25
 
26
  # Predict
27
  prediction = model.predict(img_array)
 
28
 
29
+ # Result
30
+ if prediction[0][0] > 0.5:
31
+ st.write("🔴 Disease Detected")
32
+ else:
33
+ st.write("🟢 No Disease Detected")