Spaces:
Sleeping
Sleeping
commit
Browse files- app.py +11 -5
- examples/glioma.jpg +0 -0
- examples/meningioma.jpg +0 -0
- examples/pituitary_tumor.jpg +0 -0
app.py
CHANGED
@@ -6,10 +6,8 @@ from PIL import Image
|
|
6 |
# Define model repository
|
7 |
model_name = "Aya-Ch/brain-tumor-classifier"
|
8 |
processor = AutoImageProcessor.from_pretrained(model_name)
|
9 |
-
|
10 |
model = AutoModelForImageClassification.from_pretrained(model_name)
|
11 |
|
12 |
-
|
13 |
# Define brain tumor classes
|
14 |
tumor_classes = ['meningioma', 'glioma', 'pituitary tumor']
|
15 |
|
@@ -30,15 +28,23 @@ def predict(image):
|
|
30 |
except Exception as e:
|
31 |
return {"Error": f"Failed to process image: {str(e)}"}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
# Gradio Interface
|
35 |
demo = gr.Interface(
|
36 |
fn=predict,
|
37 |
inputs=gr.Image(type="pil"), # Accepts image input
|
38 |
outputs=gr.Label(label="Tumor Classification"),
|
39 |
title="Brain Tumor Classifier",
|
40 |
-
description="Upload an MRI scan to classify the type of brain tumor(meningioma, glioma or pituitary tumor)",
|
41 |
-
allow_flagging="never"
|
|
|
|
|
42 |
)
|
43 |
|
44 |
# Launch the app
|
|
|
6 |
# Define model repository
|
7 |
model_name = "Aya-Ch/brain-tumor-classifier"
|
8 |
processor = AutoImageProcessor.from_pretrained(model_name)
|
|
|
9 |
model = AutoModelForImageClassification.from_pretrained(model_name)
|
10 |
|
|
|
11 |
# Define brain tumor classes
|
12 |
tumor_classes = ['meningioma', 'glioma', 'pituitary tumor']
|
13 |
|
|
|
28 |
except Exception as e:
|
29 |
return {"Error": f"Failed to process image: {str(e)}"}
|
30 |
|
31 |
+
# Define example images
|
32 |
+
examples = [
|
33 |
+
["examples/meningioma.jpg"],
|
34 |
+
["examples/glioma.jpg"],
|
35 |
+
["examples/pituitary_tumor.jpg"]
|
36 |
+
]
|
37 |
|
38 |
+
# Gradio Interface with Examples
|
39 |
demo = gr.Interface(
|
40 |
fn=predict,
|
41 |
inputs=gr.Image(type="pil"), # Accepts image input
|
42 |
outputs=gr.Label(label="Tumor Classification"),
|
43 |
title="Brain Tumor Classifier",
|
44 |
+
description="Upload an MRI scan to classify the type of brain tumor (meningioma, glioma or pituitary tumor)",
|
45 |
+
allow_flagging="never",
|
46 |
+
examples=examples # Add preloaded example images
|
47 |
+
|
48 |
)
|
49 |
|
50 |
# Launch the app
|
examples/glioma.jpg
ADDED
![]() |
examples/meningioma.jpg
ADDED
![]() |
examples/pituitary_tumor.jpg
ADDED
![]() |