Add model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- medical-imaging
|
| 5 |
+
- cardiac-mri
|
| 6 |
+
- segmentation
|
| 7 |
+
- attention-unet
|
| 8 |
+
- pytorch
|
| 9 |
+
datasets:
|
| 10 |
+
- ACDC
|
| 11 |
+
pipeline_tag: image-segmentation
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# ACDC Heart Segmentation — Attention U-Net Ensemble
|
| 15 |
+
|
| 16 |
+
A 5-fold cross-validated **Attention U-Net** ensemble trained on the [ACDC cardiac MRI dataset](https://www.creatis.insa-lyon.fr/Challenge/acdc/) for multi-class segmentation of cardiac structures.
|
| 17 |
+
|
| 18 |
+
## Model Description
|
| 19 |
+
|
| 20 |
+
This model segments cardiac MRI short-axis slices into 4 classes:
|
| 21 |
+
- **Class 0**: Background
|
| 22 |
+
- **Class 1**: Right Ventricle (RV)
|
| 23 |
+
- **Class 2**: Myocardium (LVM)
|
| 24 |
+
- **Class 3**: Left Ventricle (LVC)
|
| 25 |
+
|
| 26 |
+
### Architecture
|
| 27 |
+
- **Base**: U-Net with Attention Gates
|
| 28 |
+
- **Input**: Single-channel grayscale MRI (256x256)
|
| 29 |
+
- **Output**: 4-class segmentation map
|
| 30 |
+
- **Training**: 5-fold cross-validation on the ACDC training set
|
| 31 |
+
|
| 32 |
+
## Usage
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
import torch
|
| 36 |
+
from model import AttentionUNet
|
| 37 |
+
|
| 38 |
+
model = AttentionUNet(img_ch=1, output_ch=4)
|
| 39 |
+
state_dict = torch.load("fold_1_model.pth", map_location="cpu", weights_only=False)
|
| 40 |
+
if 'model_state_dict' in state_dict:
|
| 41 |
+
state_dict = state_dict['model_state_dict']
|
| 42 |
+
model.load_state_dict(state_dict)
|
| 43 |
+
model.eval()
|
| 44 |
+
|
| 45 |
+
# Input: [batch, 1, 256, 256] normalized to mean=0.5, std=0.5
|
| 46 |
+
img_tensor = torch.randn(1, 1, 256, 256)
|
| 47 |
+
with torch.no_grad():
|
| 48 |
+
output = model(img_tensor) # [batch, 4, 256, 256]
|
| 49 |
+
pred = torch.argmax(output, dim=1) # [batch, 256, 256]
|
| 50 |
+
```
|
| 51 |
+
|
| 52 |
+
## Files
|
| 53 |
+
|
| 54 |
+
| File | Description |
|
| 55 |
+
|------|-------------|
|
| 56 |
+
| `model.py` | Model architecture (AttentionUNet) |
|
| 57 |
+
| `fold_1_model.pth` - `fold_5_model.pth` | Trained weights for each CV fold |
|
| 58 |
+
|
| 59 |
+
## Training Details
|
| 60 |
+
|
| 61 |
+
- **Dataset**: ACDC (Automated Cardiac Diagnosis Challenge)
|
| 62 |
+
- **Optimizer**: Adam
|
| 63 |
+
- **Loss**: Cross-Entropy + Dice Loss
|
| 64 |
+
- **Image Size**: 256x256
|
| 65 |
+
- **Normalization**: (pixel - 0.5) / 0.5
|