asmaa1 commited on
Commit
36b1996
·
verified ·
1 Parent(s): 820ebea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -3,7 +3,7 @@ import tensorflow as tf
3
  import gradio as gr
4
  from keras.models import load_model
5
  # Load the model
6
- model = load_model('/content/drive/MyDrive/brain-tumor-mri/model/brain_tumor.keras')
7
  labels = ['glioma', 'meningioma', 'notumor', 'pituitary']
8
  def load_and_prepare_image(image_path, target_size=(224, 224)):
9
  """Load and prepare the image for prediction."""
@@ -15,7 +15,7 @@ def load_and_prepare_image(image_path, target_size=(224, 224)):
15
 
16
  def predict(image_path):
17
  if image_path is None:
18
- return "Please upload an image.", "/content/drive/MyDrive/brain-tumor-mri/images/ii.PNG"
19
 
20
  # Prepare the image
21
  img = load_and_prepare_image(image_path)
@@ -28,7 +28,7 @@ def predict(image_path):
28
  # Creative prediction message
29
  prediction_message = f'This MRI scan suggests the presence of a {predicted_label}.'
30
 
31
- return prediction_message, '/content/drive/MyDrive/brain-tumor-mri/images/ii.PNG' # Returning the image path for display
32
 
33
  # Gradio interface setup with enhancements
34
  iface = gr.Interface(
@@ -37,7 +37,7 @@ iface = gr.Interface(
37
  inputs=gr.Image(type="filepath", label="Upload MRI Image"),
38
  outputs=[
39
  gr.Textbox(label="Prediction", interactive=False, lines=2),
40
- gr.Image(value="/content/drive/MyDrive/brain-tumor-mri/images/ii.PNG", label="Always ready to assist!")
41
  ],
42
  title="🧠 Brain Tumor Classification",
43
  description="Upload a brain MRI image for analysis.",
@@ -63,7 +63,7 @@ iface = gr.Interface(
63
  color: #333;
64
  }
65
  """,
66
- examples=[["/content/drive/MyDrive/brain-tumor-mri/images/Te-noTr_0002.jpg"], ["/content/drive/MyDrive/brain-tumor-mri/images/Te-meTr_0009.jpg"]],
67
  )
68
 
69
  # Launch the interface
 
3
  import gradio as gr
4
  from keras.models import load_model
5
  # Load the model
6
+ model = load_model('brain_tumor.keras')
7
  labels = ['glioma', 'meningioma', 'notumor', 'pituitary']
8
  def load_and_prepare_image(image_path, target_size=(224, 224)):
9
  """Load and prepare the image for prediction."""
 
15
 
16
  def predict(image_path):
17
  if image_path is None:
18
+ return "Please upload an image.", "ii.PNG"
19
 
20
  # Prepare the image
21
  img = load_and_prepare_image(image_path)
 
28
  # Creative prediction message
29
  prediction_message = f'This MRI scan suggests the presence of a {predicted_label}.'
30
 
31
+ return prediction_message, 'ii.PNG' # Returning the image path for display
32
 
33
  # Gradio interface setup with enhancements
34
  iface = gr.Interface(
 
37
  inputs=gr.Image(type="filepath", label="Upload MRI Image"),
38
  outputs=[
39
  gr.Textbox(label="Prediction", interactive=False, lines=2),
40
+ gr.Image(value="ii.PNG", label="Always ready to assist!")
41
  ],
42
  title="🧠 Brain Tumor Classification",
43
  description="Upload a brain MRI image for analysis.",
 
63
  color: #333;
64
  }
65
  """,
66
+ examples=[["Te-noTr_0002.jpg"], ["Te-meTr_0009.jpg"]],
67
  )
68
 
69
  # Launch the interface