Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,98 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
datasets:
|
| 4 |
+
- SilpaCS/Augmented_alzheimer
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
base_model:
|
| 8 |
+
- google/siglip2-base-patch16-224
|
| 9 |
+
pipeline_tag: image-classification
|
| 10 |
+
library_name: transformers
|
| 11 |
+
tags:
|
| 12 |
+
- Alzheimer
|
| 13 |
+
- Stage-Classifier
|
| 14 |
+
- SigLIP2
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
# **Alzheimer-Stage-Classifier**
|
| 19 |
+
|
| 20 |
+
> **Alzheimer-Stage-Classifier** is a multi-class image classification model based on `google/siglip2-base-patch16-224`, designed to identify stages of Alzheimer’s disease from medical imaging data. This tool can assist in **clinical decision support**, **early diagnosis**, and **disease progression tracking**.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
## **Label Classes**
|
| 25 |
+
|
| 26 |
+
The model classifies input images into the following stages of Alzheimer’s disease:
|
| 27 |
+
|
| 28 |
+
```
|
| 29 |
+
0: MildDemented
|
| 30 |
+
1: ModerateDemented
|
| 31 |
+
2: NonDemented
|
| 32 |
+
3: VeryMildDemented
|
| 33 |
+
```
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## **Installation**
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install transformers torch pillow gradio
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## **Example Inference Code**
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
import gradio as gr
|
| 49 |
+
from transformers import AutoImageProcessor, SiglipForImageClassification
|
| 50 |
+
from PIL import Image
|
| 51 |
+
import torch
|
| 52 |
+
|
| 53 |
+
# Load model and processor
|
| 54 |
+
model_name = "prithivMLmods/Alzheimer-Stage-Classifier"
|
| 55 |
+
model = SiglipForImageClassification.from_pretrained(model_name)
|
| 56 |
+
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 57 |
+
|
| 58 |
+
# ID to label mapping
|
| 59 |
+
id2label = {
|
| 60 |
+
"0": "MildDemented",
|
| 61 |
+
"1": "ModerateDemented",
|
| 62 |
+
"2": "NonDemented",
|
| 63 |
+
"3": "VeryMildDemented"
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
def classify_alzheimer_stage(image):
|
| 67 |
+
image = Image.fromarray(image).convert("RGB")
|
| 68 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 69 |
+
|
| 70 |
+
with torch.no_grad():
|
| 71 |
+
outputs = model(**inputs)
|
| 72 |
+
logits = outputs.logits
|
| 73 |
+
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
|
| 74 |
+
|
| 75 |
+
prediction = {id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))}
|
| 76 |
+
return prediction
|
| 77 |
+
|
| 78 |
+
# Gradio Interface
|
| 79 |
+
iface = gr.Interface(
|
| 80 |
+
fn=classify_alzheimer_stage,
|
| 81 |
+
inputs=gr.Image(type="numpy"),
|
| 82 |
+
outputs=gr.Label(num_top_classes=4, label="Alzheimer Stage"),
|
| 83 |
+
title="Alzheimer-Stage-Classifier",
|
| 84 |
+
description="Upload a brain scan image to classify the stage of Alzheimer's: NonDemented, VeryMildDemented, MildDemented, or ModerateDemented."
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
if __name__ == "__main__":
|
| 88 |
+
iface.launch()
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
---
|
| 92 |
+
|
| 93 |
+
## **Applications**
|
| 94 |
+
|
| 95 |
+
* **Early Alzheimer’s Screening**
|
| 96 |
+
* **Clinical Diagnosis Support**
|
| 97 |
+
* **Longitudinal Study & Disease Monitoring**
|
| 98 |
+
* **Research on Cognitive Decline**
|