omm7 commited on
Commit
1f9592b
·
verified ·
1 Parent(s): 1340be0

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app.py +4 -6
Dockerfile CHANGED
@@ -11,4 +11,4 @@ COPY . .
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Run the Streamlit app
14
- CMD ["streamlit", "run", "app.py"]
 
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
  # Run the Streamlit app
14
+ CMD ["streamlit", "run", "app.py", "--server.address=0.0.0.0"]
app.py CHANGED
@@ -3,7 +3,7 @@ import numpy as np
3
  from PIL import Image
4
  from tensorflow.keras.models import load_model
5
 
6
- # Load the trained VGG16 model
7
  @st.cache_resource
8
  def load_vgg_model():
9
  return load_model("brain_tumor_vgg16_model.keras")
@@ -12,27 +12,25 @@ def load_vgg_model():
12
  st.title("Brain Tumor MRI Classification App")
13
  st.write("Upload a brain MRI scan to check if it contains a tumor.")
14
 
15
- # Load the model outside the prediction block to prevent reloading on every interaction
16
  model = load_vgg_model()
17
 
18
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
19
 
20
  if uploaded_file is not None:
21
- # Display the uploaded image
22
  image = Image.open(uploaded_file).convert("RGB")
23
  st.image(image, caption='Uploaded MRI Scan', use_column_width=True)
24
 
25
- # Preprocess the image for the model
26
  img_size = 150
27
  img_array = np.array(image.resize((img_size, img_size)))
28
  img_array = np.expand_dims(img_array, axis=0)
29
  img_array = img_array / 255.0
30
 
31
- # Make prediction
32
  prediction = model.predict(img_array)
33
  class_predicted = (prediction > 0.5).astype("int32")[0][0]
34
 
35
- # Display the result
36
  if class_predicted == 1:
37
  st.error("Prediction: Tumor Detected")
38
  else:
 
3
  from PIL import Image
4
  from tensorflow.keras.models import load_model
5
 
6
+ # Load the trained VGG16 model once
7
  @st.cache_resource
8
  def load_vgg_model():
9
  return load_model("brain_tumor_vgg16_model.keras")
 
12
  st.title("Brain Tumor MRI Classification App")
13
  st.write("Upload a brain MRI scan to check if it contains a tumor.")
14
 
15
+ # Load the model
16
  model = load_vgg_model()
17
 
18
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
19
 
20
  if uploaded_file is not None:
21
+ # Preprocess and predict
22
  image = Image.open(uploaded_file).convert("RGB")
23
  st.image(image, caption='Uploaded MRI Scan', use_column_width=True)
24
 
 
25
  img_size = 150
26
  img_array = np.array(image.resize((img_size, img_size)))
27
  img_array = np.expand_dims(img_array, axis=0)
28
  img_array = img_array / 255.0
29
 
 
30
  prediction = model.predict(img_array)
31
  class_predicted = (prediction > 0.5).astype("int32")[0][0]
32
 
33
+ # Display result
34
  if class_predicted == 1:
35
  st.error("Prediction: Tumor Detected")
36
  else: