Brain Tumor MRI Classification using Deep Learning & Explainable AI

A production-ready Artificial Intelligence system that automatically classifies brain MRI scans into Glioma, Meningioma, Pituitary Tumor, and No Tumor while generating Grad-CAM visual explanations to improve model interpretability for clinical decision support.

Overview

Brain tumors remain among the most challenging neurological conditions to diagnose accurately. Traditional MRI interpretation requires experienced radiologists and may be affected by workload, human fatigue and inter-observer variability. This project presents an end-to-end Artificial Intelligence application capable of automatically classifying brain MRI images into four clinically relevant categories while simultaneously providing visual explanations of the model's reasoning using Explainable Artificial Intelligence (XAI). Unlike many academic prototypes, this solution extends beyond model training by integrating a modern React frontend, a FastAPI inference service, cloud deployment and Grad-CAM based visual interpretation into a complete production-ready workflow.

  • Automatic classification of four brain MRI categories
  • CNN-based Deep Learning inference pipeline
  • Grad-CAM visual explanation of prediction regions
  • Interactive React web interface
  • RESTful FastAPI backend for inference
  • Cloud deployment using Render and Vercel
  • Responsive user interface suitable for desktop and mobile devices

Clinical Problem

Brain tumors can significantly impact neurological function and often require rapid diagnosis. Magnetic Resonance Imaging (MRI) is considered the preferred imaging modality due to its superior soft tissue contrast. However, manual interpretation presents several challenges including:

  • Growing radiology workload worldwide.
  • Time-consuming image interpretation.
  • Variability between radiologists.
  • Difficulty detecting subtle tumor boundaries.
  • Limited access to specialist expertise in underserved regions.

Artificial Intelligence provides an opportunity to accelerate preliminary image assessment, support clinical workflows and improve consistency while maintaining physician oversight.

Brain Tumor MRI Application Homepage
Landing page of the Brain Tumor MRI Classification application.

Deep Learning Pipeline

The project follows a complete deep learning workflow beginning with MRI preprocessing, dataset preparation and augmentation, model development, evaluation, explainability and deployment.

  • Brain MRI dataset organization into four diagnostic categories.
  • Image resizing to 224 × 224 pixels.
  • Pixel normalization using TensorFlow preprocessing layers.
  • Real-time augmentation through random flipping, rotation, translation and zoom.
  • CNN training using TensorFlow/Keras.
  • Early stopping and learning-rate scheduling.
  • Best model checkpoint preservation.
  • Deployment-ready model serialization.
Brain Tumor Workflow
Complete machine learning workflow from MRI acquisition through deployment.

CNN Model Architecture

The classification engine was developed using TensorFlow and Keras. Rather than relying on transfer learning, this implementation uses a custom Convolutional Neural Network designed specifically for four-class MRI classification while maintaining computational efficiency.

  • Input Resolution: 224 × 224 RGB
  • Three Convolutional Blocks
  • Batch Normalization after each convolution
  • Max Pooling for feature reduction
  • Global Average Pooling Layer
  • Dense Layer (256 neurons)
  • Dropout (0.5)
  • Dense Layer (128 neurons)
  • Dropout (0.3)
  • Softmax Output Layer (4 Classes)

Training employed the Adam optimizer with categorical cross-entropy loss while incorporating EarlyStopping, ReduceLROnPlateau and ModelCheckpoint callbacks to improve convergence and reduce overfitting.

Explainable Artificial Intelligence (Grad-CAM)

One of the major limitations of deep learning in healthcare is the "black-box" nature of model predictions. To improve transparency, this project integrates Gradient-weighted Class Activation Mapping (Grad-CAM), enabling clinicians and users to visualize the image regions that contributed most strongly to the model's decision.

  • Automatic Grad-CAM generation after every prediction.
  • Heatmap overlay on the original MRI scan.
  • Visual interpretation of tumor localization.
  • Supports explainable clinical decision support.
  • Improves user confidence and model transparency.

Application Features

Beyond model development, the project delivers a complete full-stack AI application capable of performing real-time MRI classification through an intuitive user interface.

  • Drag-and-drop MRI upload.
  • Sample MRI testing.
  • Real-time prediction.
  • Prediction confidence score.
  • Class probability distribution.
  • Grad-CAM visualization.
  • Responsive interface.
  • REST API communication.

Deployment Architecture

The solution was deployed as a cloud-native application separating inference from presentation. This architecture enables independent frontend and backend scaling while simplifying maintenance and continuous deployment.

  • Frontend deployed on Vercel.
  • Backend deployed on Render.
  • TensorFlow model served through FastAPI.
  • Axios REST communication.
  • CORS-enabled API.
  • GitHub-based CI/CD deployment.
  • Environment-variable configuration.
  • Production-ready architecture.
Deployment Architecture
Production deployment architecture using React, FastAPI, Render and Vercel.

Clinical & Business Impact

This project demonstrates how modern Deep Learning can be integrated into practical healthcare applications to assist clinicians, researchers, and healthcare organizations in performing rapid MRI image classification while improving model transparency through Explainable AI. Although intended as a research and educational system rather than a certified medical device, the solution showcases how AI can augment diagnostic workflows and accelerate decision support.

  • Accelerates preliminary MRI assessment.
  • Supports radiologists with AI-assisted predictions.
  • Improves transparency through Explainable AI.
  • Reduces repetitive manual screening workload.
  • Demonstrates production-ready AI deployment.
  • Provides an educational platform for Deep Learning and Computer Vision.
  • Serves as a foundation for future clinical decision-support systems.

Technology Stack

  • Programming Language: Python, JavaScript
  • Deep Learning: TensorFlow, Keras
  • Computer Vision: OpenCV, Pillow
  • Numerical Computing: NumPy
  • Backend: FastAPI
  • Frontend: React.js, Vite, Tailwind CSS
  • HTTP Client: Axios
  • Explainability: Grad-CAM
  • Deployment: Render, Vercel
  • Version Control: Git & GitHub