omm7 commited on
Commit
d23ba8f
·
verified ·
1 Parent(s): 4886fee

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ brain_tumor_vgg16_model.keras filter=lfs diff=lfs merge=lfs -text
.streamlit/config.toml ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [global]
2
+ dataFrameSerialization = "legacy"
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ # Create a non-root user
4
+ RUN adduser --disabled-password --gecos '' streamlit-user
5
+
6
+ WORKDIR /app
7
+
8
+ COPY . .
9
+
10
+ # Set Streamlit's config directory to the current working directory
11
+ ENV STREAMLIT_SERVER_CONFIG_FILE=/app/.streamlit/config.toml
12
+
13
+ # Install dependencies as the non-root user
14
+ USER streamlit-user
15
+ RUN pip3 install --no-cache-dir -r requirements.txt
16
+
17
+ EXPOSE 8501
18
+
19
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from PIL import Image
4
+ from tensorflow.keras.models import load_model
5
+ from tensorflow.keras.preprocessing.image import ImageDataGenerator
6
+
7
+ # Load the trained VGG16 model
8
+ @st.cache_resource
9
+ def load_vgg_model():
10
+ return load_model("brain_tumor_vgg16_model.keras")
11
+
12
+ model = load_vgg_model()
13
+ img_size = 150
14
+
15
+ # Streamlit UI
16
+ st.title("Brain Tumor MRI Classification App")
17
+ st.write("Upload a brain MRI scan to check if it contains a tumor.")
18
+
19
+ uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
20
+
21
+ if uploaded_file is not None:
22
+ # Display the uploaded image
23
+ image = Image.open(uploaded_file).convert("RGB")
24
+ st.image(image, caption='Uploaded MRI Scan', use_column_width=True)
25
+ st.write("")
26
+ st.write("Classifying...")
27
+
28
+ # Preprocess the image for the model
29
+ img_array = np.array(image.resize((img_size, img_size)))
30
+ img_array = np.expand_dims(img_array, axis=0)
31
+ img_array = img_array / 255.0 # Rescale to [0, 1]
32
+
33
+ # Make prediction
34
+ prediction = model.predict(img_array)
35
+ class_predicted = (prediction > 0.5).astype("int32")[0][0]
36
+
37
+ # Display the result
38
+ if class_predicted == 1:
39
+ st.error("Prediction: Tumor Detected")
40
+ else:
41
+ st.success("Prediction: No Tumor Detected")
brain_tumor_vgg16_model.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cad45eb1560e9ffabdba98c067cdc5063779c375cc8d673a7bb3da261734c749
3
+ size 84124079
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ numpy
2
+ tensorflow
3
+ streamlit
4
+ Pillow
5
+ huggingface_hub