Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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
|
| 8 |
-
model = load_model("
|
| 9 |
|
| 10 |
-
|
| 11 |
-
st.
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
uploaded_file = st.file_uploader("
|
| 15 |
|
| 16 |
if uploaded_file is not None:
|
| 17 |
-
#
|
| 18 |
img = Image.open(uploaded_file)
|
| 19 |
st.image(img, caption="Uploaded Image", use_column_width=True)
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
img = img.resize((64, 64)) #
|
| 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 |
-
result = "🧠 Brain Tumor Detected" if prediction[0][0] > 0.5 else "✅ No Brain Tumor Detected"
|
| 29 |
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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")
|