Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
def alz_mri_classification(image):
|
| 4 |
+
classifier = pipeline("image-classification", model="dewifaj/alzheimer_mri_classification")
|
| 5 |
+
result = classifier(image)
|
| 6 |
+
# extract the highest score
|
| 7 |
+
prediction = result[0]
|
| 8 |
+
score = prediction['score']
|
| 9 |
+
label = prediction['label']
|
| 10 |
+
return {"score": score, "label": label}
|
| 11 |
+
|
| 12 |
+
example_image_paths = ["Very_Mild_Demented.png",
|
| 13 |
+
"Mild_Demented.png",
|
| 14 |
+
"Moderate_Demented.png",
|
| 15 |
+
"Non_Demented.png"]
|
| 16 |
+
|
| 17 |
+
image_input = gr.Image(type="pil", label="Upload Image")
|
| 18 |
+
iface = gr.Interface(fn=alz_mri_classification,
|
| 19 |
+
inputs=image_input,
|
| 20 |
+
outputs="json",
|
| 21 |
+
examples=example_image_paths,
|
| 22 |
+
title="Alzheimer Recognition from MRI")
|
| 23 |
+
iface.launch(share=True)
|