ResNet18 brain MRI tumour classifier

Research and educational use only. This is not a medical device and must not be used for diagnosis or any clinical decision.

Model description

A ResNet18 (ImageNet-pretrained, torchvision) fine-tuned to classify a single 2D brain MRI slice into one of four classes: glioma, meningioma, no tumour, pituitary tumour. Outputs are temperature-scaled (T = 1.746, fitted on the validation set) so that probabilities are better calibrated.

Intended use

  • Learning and portfolio demonstration of an end-to-end ML workflow
  • Exploring model behaviour, calibration and failure modes

Out-of-scope use

  • Any clinical, diagnostic or screening use

  • CT scans or other imaging modalities (trained on MRI only)

  • 3D volumes, other body regions, or populations unlike the training data

Limitations

  • Source differences between classes. The dataset merges several public sources. "No tumour" images mostly come from a different source and are smaller and stored as RGB, so the model may partly learn image source rather than anatomy. A resolution-only test (100 images) did not change predictions, but other source traits were not tested.

  • Possible residual leakage. The original Kaggle split contained duplicate scans across train and test. I re-split with exact perceptual-hash grouping; near-duplicates and different slices of the same patient may still cross splits, since the dataset has no patient IDs.

  • Confidently wrong on unfamiliar images. A test scan that appears to be CT, not MRI, was classified as "no tumour" with 98.9% confidence. High confidence does not guarantee correctness on out-of-distribution inputs.

  • Errors concentrate in one image type. 16 of the 17 test tumours predicted as "no tumour" were RGB, lower-resolution images (vs 46% RGB among all test tumours). Meningioma has the lowest test recall (90.7%).

  • Not representative of clinical data. Classes are artificially balanced, there is no external validation, and test metrics come from one public dataset. Real-world performance would likely be lower.

    Training data

  • Kaggle "Brain Tumor MRI Dataset" (masoudnickparvar); the version used had 7,200 images, 1,800 per class. See the dataset page for its licence.

  • The official train/test split was pooled and re-split 60/20/20 with StratifiedGroupKFold, grouping images by perceptual hash (dHash) so duplicate images never cross splits. Verified: 0 shared groups.

  • Training augmentation: random rotation (ยฑ10ยฐ) only.

Training procedure

  • ImageNet-pretrained ResNet18 (torchvision)
  • Stage 1: new 4-class head only, backbone frozen, Adam, lr 1e-3
  • Stage 2: full fine-tuning, Adam, lr 1e-4, 10 epochs; BatchNorm statistics kept frozen; checkpoint chosen by lowest validation loss

Evaluation

Held-out test set (1,429 images), used once after all choices were fixed.

Class Precision Recall
Glioma 0.959 0.935
Meningioma 0.943 0.907
No tumour 0.956 0.984
Pituitary 0.962 0.997
  • Accuracy: 95.5% (validation was 97.1%; the gap reflects checkpoint selection on validation). From-scratch CNN baseline: 85.0%.
  • 17 of 1,051 tumour scans were predicted "no tumour"; 6 of 378 no-tumour scans were predicted as a tumour.
  • Calibration (ECE, 10 bins): 0.026 before and 0.010 after temperature scaling.
  • Grad-CAM maps were sanity-checked (class-specific; random weights give noise). For correct predictions, evidence falls inside the brain near the lesion region; maps are coarse (7ร—7) and are not proof of clinical reasoning.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Space using Keerthisuresh12/mri-resnet18 1