Projects

January 2025 - May 2025

Cardiac MRI Classification (Comparative Study)

Technologies: Deep Learning - MobileNetV2, ResNet152V2, DenseNet201, InceptionV3

I trained four deep learning models on 63k cardiac MRI images to find out whether attention helps. It didn't.

Visit source
Cardiac MRI Classification (Comparative Study) cover image

I took a big cardiac MRI dataset, pointed four deep learning architectures at the same job of telling normal scans from sick ones, and compared how each one behaved. Mostly I wanted to know whether adding attention helps. On this dataset it doesn't.

The setup

The dataset has roughly 63,000 cardiac MRI images. I compared four transfer-learning architectures on the same task:

  • MobileNetV2
  • ResNet152V2
  • DenseNet201
  • InceptionV3

I didn't want to crown a winner before training started. I wanted to see how each model trained, where it struggled, what changed with augmentation and class weighting, and whether attention improved the results or only made the pipeline look fancier.

It's easy to make an ML project look sophisticated. You add a block, add a graph, drop in a term from a paper, and none of it has to make the model any better. I wanted mine to survive someone reading the code and the numbers.

Training

I worked through transfer learning, data augmentation, class weighting, a spatial attention block and an attention ensemble, and tracked what each one changed in how the models behaved.

The dataset has about 1.5 normal images for every sick one, so class weighting wasn't optional.

The results

Here is accuracy on the 20% validation split, with and without the spatial attention block:

ModelBaselineWith attention
MobileNetV276.18%72.67%
ResNet152V277.44%74.09%
DenseNet20176.31%74.39%
InceptionV370.15%70.36%

Attention cost three of the four models between 1.9 and 3.5 points of accuracy, and moved InceptionV3 by 0.2.

The best single model was the plain ResNet152V2 baseline at 77.44%. MobileNetV2, the smallest of the four, had the best balanced accuracy at 78.15%. Averaging the attention models into an ensemble reached 77.80%, the highest accuracy in the study and 0.36 points above the best single model.

So no, attention didn't help here. It made the pipeline look fancier and the numbers worse. That's a negative result, and I'd rather report it than hide it.

There's no separate test set, so read these numbers as a comparison between models and nothing more.

What I took from it

In medical imaging a confidently wrong prediction is dangerous, even in research, so an accuracy number on its own doesn't mean much. That's why the repo ships saved checkpoints, evaluation plots, reproducible training flows and the paper, and anyone can check my results themselves.

This project made me a more careful ML engineer. Anyone can get a notebook to run. I built a training and evaluation pipeline that someone else can pick up, rerun and argue with, which took a lot more work. I also trust models less than I used to, so before I believe a number I check the preprocessing, whether the run repeats, and whether the pipeline is doing what I think it's doing.

Projects

January 2025 - May 2025

Cardiac MRI Classification (Comparative Study)

Technologies: Deep Learning - MobileNetV2, ResNet152V2, DenseNet201, InceptionV3

I trained four deep learning models on 63k cardiac MRI images to find out whether attention helps. It didn't.

Visit source
Cardiac MRI Classification (Comparative Study) cover image

I took a big cardiac MRI dataset, pointed four deep learning architectures at the same job of telling normal scans from sick ones, and compared how each one behaved. Mostly I wanted to know whether adding attention helps. On this dataset it doesn't.

The setup

The dataset has roughly 63,000 cardiac MRI images. I compared four transfer-learning architectures on the same task:

  • MobileNetV2
  • ResNet152V2
  • DenseNet201
  • InceptionV3

I didn't want to crown a winner before training started. I wanted to see how each model trained, where it struggled, what changed with augmentation and class weighting, and whether attention improved the results or only made the pipeline look fancier.

It's easy to make an ML project look sophisticated. You add a block, add a graph, drop in a term from a paper, and none of it has to make the model any better. I wanted mine to survive someone reading the code and the numbers.

Training

I worked through transfer learning, data augmentation, class weighting, a spatial attention block and an attention ensemble, and tracked what each one changed in how the models behaved.

The dataset has about 1.5 normal images for every sick one, so class weighting wasn't optional.

The results

Here is accuracy on the 20% validation split, with and without the spatial attention block:

ModelBaselineWith attention
MobileNetV276.18%72.67%
ResNet152V277.44%74.09%
DenseNet20176.31%74.39%
InceptionV370.15%70.36%

Attention cost three of the four models between 1.9 and 3.5 points of accuracy, and moved InceptionV3 by 0.2.

The best single model was the plain ResNet152V2 baseline at 77.44%. MobileNetV2, the smallest of the four, had the best balanced accuracy at 78.15%. Averaging the attention models into an ensemble reached 77.80%, the highest accuracy in the study and 0.36 points above the best single model.

So no, attention didn't help here. It made the pipeline look fancier and the numbers worse. That's a negative result, and I'd rather report it than hide it.

There's no separate test set, so read these numbers as a comparison between models and nothing more.

What I took from it

In medical imaging a confidently wrong prediction is dangerous, even in research, so an accuracy number on its own doesn't mean much. That's why the repo ships saved checkpoints, evaluation plots, reproducible training flows and the paper, and anyone can check my results themselves.

This project made me a more careful ML engineer. Anyone can get a notebook to run. I built a training and evaluation pipeline that someone else can pick up, rerun and argue with, which took a lot more work. I also trust models less than I used to, so before I believe a number I check the preprocessing, whether the run repeats, and whether the pipeline is doing what I think it's doing.