Spaces:
Sleeping
Sleeping
Download app.py from dewifaj/mri_classification: direct link, hf CLI and curl.
- Browser
- Download file 884 Bytes
-
https://huggingface.co/spaces/dewifaj/mri_classification/resolve/main/app.py
- Command line
-
hf download hf://spaces/dewifaj/mri_classification/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dewifaj/mri_classification/resolve/main/app.py
884 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| def alz_mri_classification(image): | |
| classifier = pipeline("image-classification", model="dewifaj/alzheimer_classification") | |
| result = classifier(image) | |
| # extract the highest score | |
| prediction = result[0] | |
| score = prediction['score'] | |
| label = prediction['label'] | |
| return {"score": score, "label": label} | |
| example_image_paths = ["Very_Mild_Demented.png", | |
| "Mild_Demented.png", | |
| "Moderate_Demented.png", | |
| "Non_Demented.png"] | |
| image_input = gr.Image(type="pil", label="Upload Image") | |
| iface = gr.Interface(fn=alz_mri_classification, | |
| inputs=image_input, | |
| outputs="json", | |
| examples=example_image_paths, | |
| title="Alzheimer Recognition from MRI") | |
| iface.launch() |