Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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('
|
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.", "
|
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, '
|
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="
|
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=[["
|
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
|