Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- pytorch
|
| 4 |
+
- medical-imaging
|
| 5 |
+
- semantic-segmentation
|
| 6 |
+
- cardiac-mri
|
| 7 |
+
- densenet
|
| 8 |
+
- computer-vision
|
| 9 |
+
license: mit
|
| 10 |
+
datasets:
|
| 11 |
+
- cardiac-mri
|
| 12 |
+
metrics:
|
| 13 |
+
- dice-coefficient
|
| 14 |
+
- iou
|
| 15 |
+
library_name: pytorch
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Cardiac Pathology Prediction - DenseNet
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
This is a custom-implemented **DenseNet** for cardiac MRI segmentation and pathology prediction. The model performs semantic segmentation of cardiac structures (left ventricle, right ventricle, and myocardium) from short-axis cardiac cine MR images.
|
| 23 |
+
|
| 24 |
+
### Key Features
|
| 25 |
+
- 🏗️ Fully Convolutional DenseNet architecture implemented from scratch
|
| 26 |
+
- 🫀 4-class semantic segmentation (background, LV, RV, myocardium)
|
| 27 |
+
- 🔬 Trained on NIfTI format cardiac MRI data
|
| 28 |
+
- 📊 Combined Cross-Entropy and Dice Loss
|
| 29 |
+
- 🎯 Designed for cardiac pathology classification
|
| 30 |
+
|
| 31 |
+
## Architecture
|
| 32 |
+
|
| 33 |
+
The model follows a U-Net style encoder-decoder architecture with dense blocks:
|
| 34 |
+
|
| 35 |
+
- **Input**: Single-channel 2D cardiac MRI slices (128×128)
|
| 36 |
+
- **Encoder**: 3 dense blocks (3, 4, 5 layers) with transition down
|
| 37 |
+
- **Bottleneck**: Dense block with 8 layers
|
| 38 |
+
- **Decoder**: 3 dense blocks (5, 4, 3 layers) with skip connections
|
| 39 |
+
- **Output**: 4-channel probability map (softmax activated)
|
| 40 |
+
- **Growth rate**: 8 (bottleneck: 7)
|
| 41 |
+
|
| 42 |
+
## Intended Use
|
| 43 |
+
|
| 44 |
+
This model is designed for:
|
| 45 |
+
- Cardiac MRI segmentation research
|
| 46 |
+
- Educational purposes in medical image analysis
|
| 47 |
+
- Baseline comparison for cardiac segmentation tasks
|
| 48 |
+
- Feature extraction for cardiac pathology classification
|
| 49 |
+
|
| 50 |
+
**Note**: This model is for research purposes only and not intended for clinical use.
|
| 51 |
+
|
| 52 |
+
## Training Details
|
| 53 |
+
|
| 54 |
+
- **Loss Function**: Combined Cross-Entropy and Dice Loss (α=0.25)
|
| 55 |
+
- **Optimizer**: Adam
|
| 56 |
+
- **Framework**: PyTorch 2.6.0
|
| 57 |
+
- **Data Format**: NIfTI (.nii) files
|
| 58 |
+
- **Image Size**: 128×128 pixels
|
| 59 |
+
- **Preprocessing**: ROI extraction, normalization, data augmentation
|
| 60 |
+
|
| 61 |
+
## How to Use
|
| 62 |
+
|
| 63 |
+
```python
|
| 64 |
+
import torch
|
| 65 |
+
from densenet.densenet import DenseNet
|
| 66 |
+
|
| 67 |
+
# Load the model
|
| 68 |
+
model = DenseNet()
|
| 69 |
+
model.load_state_dict(torch.load('model_weights.pth', map_location='cpu'))
|
| 70 |
+
model.eval()
|
| 71 |
+
|
| 72 |
+
# Inference
|
| 73 |
+
with torch.no_grad():
|
| 74 |
+
# input_image: (1, 1, 128, 128) tensor
|
| 75 |
+
output = model(input_image) # (1, 4, 128, 128)
|
| 76 |
+
prediction = torch.argmax(output, dim=1) # Get class predictions
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
## Model Files
|
| 80 |
+
|
| 81 |
+
- `model_weights.pth`: Complete model checkpoint including weights and optimizer state
|
| 82 |
+
- `densenet/`: Source code for the DenseNet architecture
|
| 83 |
+
- Full implementation available at: [GitHub Repository](https://github.com/NicolasNoya/CardiacPathologyPrediction)
|
| 84 |
+
|
| 85 |
+
## Citation
|
| 86 |
+
|
| 87 |
+
If you use this model, please cite the original paper that inspired this implementation:
|
| 88 |
+
|
| 89 |
+
```
|
| 90 |
+
Densely Connected Fully Convolutional Network for Short-Axis Cardiac Cine MR Image
|
| 91 |
+
Segmentation and Heart Diagnosis Using Random Forest
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
## Author
|
| 95 |
+
|
| 96 |
+
**Francisco Nicolás Noya**
|
| 97 |
+
- GitHub: [@NicolasNoya](https://github.com/NicolasNoya)
|
| 98 |
+
- Project: IMA205 Challenge
|
| 99 |
+
|
| 100 |
+
## License
|
| 101 |
+
|
| 102 |
+
MIT License - See repository for details.
|
| 103 |
+
|
| 104 |
+
## Disclaimer
|
| 105 |
+
|
| 106 |
+
This model is provided for research and educational purposes only. It has not been clinically validated and should not be used for medical diagnosis or treatment decisions.
|