swin-tiny-patch4-window7-224-finetuned-mri
Swin-Tiny fine-tuned to classify cardiac MRI images as cad (coronary artery disease) or healthy.
Research artifact from a 2022 master's thesis. Not a medical device and not for clinical use.
Context
This checkpoint comes from the co-authored M.Sc. thesis Novel Deep Learning Architecture for Predicting Heart Diseases based on Transformers and Attention Mechanism with Explainability Model by Raedin Khaled Sakhri and Loutfi Boufeligha, supervised by Prof. Abdelouaheb Moussaoui (Ferhat Abbas University, Algeria, July 2022). The thesis compared eight models on the same task. This one is the fine-tuned Swin-Tiny, pretrained on ImageNet-1k.
Data
- CAD Cardiac MRI Dataset, as referenced in the thesis: Kaggle. 63,425 images: 25,861 healthy and 37,564 sick, so the classes are imbalanced. Check the dataset page for its terms of use.
- Images were converted to RGB and resized to 224 × 224, with the model's feature extractor for normalization.
- This run split the image folder 90/10: 57,231 training and 6,360 evaluation images (training log).
Results
| Epoch | Training loss | Validation loss | Accuracy |
|---|---|---|---|
| 1 | 0.0592 | 0.0823 | 0.9695 |
| 2 | 0.0196 | 0.0761 | 0.9739 |
| 3 | 0.0058 | 0.0608 | 0.9807 |
The Trainer logged about 6.1 hours of training for the 3 epochs; the thesis rounds this to about 7 hours. For comparison, in the thesis: ViT-Base 98.27%, DeiT 99.01% (overfitting noted), a Vision Transformer trained from scratch 75.73%, and a CNN 88%.
Training
- Hugging Face Transformers 4.20.0, PyTorch 1.11.0+cu113, Datasets 2.3.2, Tokenizers 0.12.1, on Google Colab
- learning_rate 5e-05, train and eval batch 32, gradient accumulation 4 (total batch 128), seed 42
- Adam (betas 0.9/0.999, epsilon 1e-08), linear schedule with 10% warmup, 3 epochs
- mixed precision: Native AMP
Limitations
- One public dataset. No external or patient-level validation, so behavior on other scanners, hospitals or populations is unknown.
- The thesis does not document whether images from the same patient were kept in one split, so overlap between training and evaluation cannot be ruled out.
- Only accuracy is reported. Precision, recall and F1 were not measured.
- For research and education only.
Usage
from transformers import pipeline
classifier = pipeline("image-classification", model="raedinkhaled/swin-tiny-patch4-window7-224-finetuned-mri")
print(classifier("cardiac_mri_slice.png"))