Skip to content
← Back to projects

Brain Tumor Detection from MRI Images

A deep learning image classifier that detects brain tumors in MRI scans, comparing a custom CNN against transfer learning with MobileNetV2 and ResNet50 on a small medical dataset.

By Jawher Ennaceur

View on GitHub
  • Deep Learning
  • Computer Vision
  • Transfer Learning
  • CNN
  • Medical Imaging
  • TensorFlow

The Problem

Detecting tumors in MRI scans manually is slow and depends on specialist time. The goal was a model that classifies a scan as tumor or no tumor, using only about 250 labeled images, where a network trained from scratch is likely to overfit.

The Approach

I loaded the images with Keras ImageDataGenerator, resized them to 224x224 and applied data augmentation (small rotations and shifts, zoom, horizontal and vertical flips, brightness changes) with an 80/20 train/validation split (203 training and 50 validation images). I then trained and compared three models for 20 epochs each with categorical cross-entropy: a custom CNN with three convolution and max-pooling blocks and a dropout-regularized dense head; a MobileNetV2 model pre-trained on ImageNet with a frozen base, global average pooling and a 512-unit dense layer; and a ResNet50-based model with batch normalization trained with RMSprop. I tracked accuracy and loss curves per epoch to compare how each model generalized.

Results

  • MobileNetV2 transfer learning reached about 96% training accuracy and 90-98% validation accuracy over the last 10 epochs
  • The custom CNN trained from scratch plateaued at roughly 72-76% validation accuracy, showing the benefit of pre-trained features on a small dataset
  • The ResNet50-based model reached about 76% validation accuracy with the settings tried
  • Used data augmentation and a frozen pre-trained base to limit overfitting on only ~250 images
  • Evaluated on a 50-image validation split; no separate held-out test set

Tech Stack

PythonTensorFlowKerasMobileNetV2ResNet50NumPyMatplotlibGoogle Colab