Skip to content

Latest commit

Β 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Explainable Brain Tumor Detection Banner

🧠 Explainable Brain Tumor Detection using Deep Learning

An AI-powered medical imaging system that automatically detects and classifies brain tumors from MRI scans using a Convolutional Neural Network (CNN) integrated with Explainable Artificial Intelligence (Grad-CAM). The application combines deep learning with visual interpretability to provide transparent predictions, confidence analysis, probability visualization, and downloadable clinical-style reports through an interactive Streamlit web application.


🌐 Live Demo

πŸš€ Experience the Application

https://brain-mri-ai.streamlit.app/


🧠 Project Overview

Brain tumor diagnosis is a critical task in medical imaging where timely and accurate interpretation of MRI scans plays a significant role in clinical decision-making. Deep learning has demonstrated remarkable performance in medical image analysis; however, most models function as black boxes, making it difficult to understand the reasoning behind their predictions.

This project presents an Explainable Artificial Intelligence (XAI) framework for multiclass brain tumor detection and classification using Convolutional Neural Networks (CNNs). To improve transparency and interpretability, the model integrates Gradient-weighted Class Activation Mapping (Grad-CAM), enabling visualization of the image regions that contribute most to the model's predictions.

The application is deployed as an interactive Streamlit web application where users can upload MRI scans, receive real-time predictions, analyze confidence scores and probability distributions, visualize Grad-CAM heatmaps, and generate downloadable clinical-style PDF reports.

The project demonstrates the integration of medical image preprocessing, deep learning, computer vision, Explainable AI, and interactive deployment into a unified diagnostic support system.

Disclaimer: This project is developed solely for educational and research purposes. It is not intended to replace professional medical diagnosis or clinical decision-making.


πŸš€ Key Features

🧠 Deep Learning-Based Classification

  • Automatic Brain Tumor Detection
  • Four-Class MRI Classification
  • CNN-Based Prediction Engine
  • Softmax Probability Distribution

πŸ”₯ Explainable Artificial Intelligence

  • Grad-CAM Heatmap Generation
  • Visual Interpretation of Model Decisions
  • Explainable Predictions
  • Improved Model Transparency

πŸ“Š Intelligent Prediction Analysis

  • Prediction Confidence Score
  • Class Probability Distribution
  • Uncertainty Detection
  • Clinical Interpretation

πŸ“„ Automated Medical Reporting

  • Clinical-Style PDF Report Generation
  • Prediction Summary
  • Embedded Grad-CAM Visualization
  • AI Verification Stamp

🌐 Interactive Web Application

  • Streamlit-Based User Interface
  • Drag-and-Drop MRI Upload
  • Real-Time Prediction
  • Responsive and User-Friendly Experience

🧬 Supported Classification Categories

Tumor Type Description
🟣 Glioma Tumors originating from glial cells within the brain and spinal cord.
πŸ”΅ Meningioma Tumors developing from the meninges, the protective membranes surrounding the brain and spinal cord.
🟠 Pituitary Tumors affecting the pituitary gland located at the base of the brain.
🟒 No Tumor MRI scans without detectable tumor abnormalities.

πŸ›  Technology Stack

Category Technologies
Programming Language Python
Deep Learning TensorFlow, Keras
Computer Vision OpenCV
Data Processing NumPy, Pandas
Data Visualization Matplotlib
Explainable AI Grad-CAM
Web Framework Streamlit
Report Generation ReportLab
Development Environment Jupyter Notebook, VS Code

πŸ—‚ Dataset Overview

The model is trained on a publicly available Brain MRI Dataset containing four different categories of brain MRI images.

Dataset Classes

Class Description
Glioma Brain tumors originating from glial cells
Meningioma Tumors affecting the protective membranes of the brain
Pituitary Tumors occurring in the pituitary gland
No Tumor Healthy brain MRI images without tumor abnormalities

The dataset was divided into training and testing subsets to evaluate the model's generalization capability while maintaining balanced class representation.


πŸ§ͺ Image Preprocessing Pipeline

Medical images require preprocessing before being used for deep learning to improve consistency and model performance.

The preprocessing pipeline includes:

  • RGB Image Conversion
  • Brain Region Extraction
  • Contrast Enhancement
  • Gaussian Noise Reduction
  • Image Resizing (224 Γ— 224)
  • Pixel Normalization

These preprocessing steps improve feature extraction while reducing noise and variations present in MRI scans.


🧠 CNN Model Architecture

The classification model is built using a custom Convolutional Neural Network (CNN) designed for multiclass brain tumor classification.

Model Components

  • Convolutional Layers
  • ReLU Activation
  • Max Pooling Layers
  • Dropout Regularization
  • Fully Connected Dense Layers
  • Softmax Output Layer

The network progressively extracts low-level and high-level image features before classifying MRI scans into one of the four supported tumor categories.


πŸ”₯ Explainable Artificial Intelligence (Grad-CAM)

Traditional deep learning models often behave as black-box systems, making it difficult to understand how predictions are generated.

To improve transparency, this project integrates Gradient-weighted Class Activation Mapping (Grad-CAM).

Grad-CAM produces visual heatmaps that highlight the regions of an MRI scan contributing most to the model's prediction, enabling users to better understand the reasoning behind the classification.

Benefits of Explainability

  • Improved model transparency
  • Better prediction interpretability
  • Increased user confidence
  • Educational visualization for AI-assisted diagnosis

Note: Grad-CAM highlights influential image regions and should not be interpreted as an exact tumor segmentation method.


βš™ System Workflow

                MRI Brain Image
                       β”‚
                       β–Ό
              Image Preprocessing
                       β”‚
                       β–Ό
               CNN Classification
                       β”‚
                       β–Ό
            Probability Distribution
                       β”‚
                       β–Ό
              Confidence Analysis
                       β”‚
                       β–Ό
           Grad-CAM Heatmap Generation
                       β”‚
                       β–Ό
            Clinical Interpretation
                       β”‚
                       β–Ό
            Downloadable PDF Report

πŸ“‚ Project Structure

Explainable-Brain-Tumor-Detection
β”‚
β”œβ”€β”€ assets
β”‚   β”œβ”€β”€ banner
β”‚   β”‚   └── banner.png
β”‚   β”‚
β”‚   β”œβ”€β”€ icons
β”‚   β”‚   └── ai_stamp.png
β”‚   β”‚
β”‚   └── screenshots
β”‚       β”œβ”€β”€ ui_main.png
β”‚       β”œβ”€β”€ prediction_output.png
β”‚       β”œβ”€β”€ gradcam_output.png
β”‚       β”œβ”€β”€ preprocessing.png
β”‚       └── report_output.png
β”‚
β”œβ”€β”€ dataset
β”‚   β”œβ”€β”€ Training
β”‚   └── Testing
β”‚
β”œβ”€β”€ docs
β”‚   β”œβ”€β”€ Project_Report.pdf
β”‚   └── Research_Paper.pdf
β”‚
β”œβ”€β”€ model
β”‚   β”œβ”€β”€ model_loader.py
β”‚   └── multiclass_brain_tumor_cnn.h5
β”‚
β”œβ”€β”€ utils
β”‚   β”œβ”€β”€ gradcam.py
β”‚   β”œβ”€β”€ preprocess.py
β”‚   └── report.py
β”‚
β”œβ”€β”€ app.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── .gitignore

🎯 Core Functionalities

  • Brain MRI Classification
  • Image Quality Assessment
  • MRI Image Preprocessing
  • CNN-Based Prediction
  • Confidence Analysis
  • Probability Visualization
  • Grad-CAM Explainability
  • Clinical Interpretation
  • PDF Report Generation
  • Interactive Streamlit Interface

πŸ“Š Model Performance

The developed CNN model demonstrates strong performance in multiclass brain tumor classification while maintaining prediction transparency through Explainable AI.

Evaluation Metrics

  • Overall Classification Accuracy: ~91%
  • Precision, Recall, and F1-Score Evaluation
  • Confusion Matrix Analysis
  • Softmax Probability Distribution
  • Grad-CAM Visual Validation

The combination of quantitative metrics and visual explanations enables a more interpretable AI-assisted diagnostic workflow.


πŸ“Έ Application Screenshots

πŸ–₯️ Home Interface


πŸ“Š Prediction Output


πŸ”₯ Grad-CAM Visualization


πŸ“„ Clinical Report


πŸ§ͺ Image Preprocessing


πŸ“₯ Trained Model

The trained CNN model is not included in this repository because of GitHub's file size limitations.

Download the trained model from the link below and place it inside the model/ directory.

Google Drive

https://drive.google.com/drive/folders/1J6zwcEmjOlWpcxnOJCGMR1g0edaYCM2G?usp=sharing

model/
└── multiclass_brain_tumor_cnn.h5

πŸš€ Getting Started

Clone Repository

git clone https://github.com/TanmayT134/Explainable-Brain-Tumor-Detection.git

cd Explainable-Brain-Tumor-Detection

Create Virtual Environment

python -m venv venv

Activate Virtual Environment

Windows

venv\Scripts\activate

macOS / Linux

source venv/bin/activate

Install Dependencies

pip install -r requirements.txt

Run the Application

streamlit run app.py

The application will automatically open in your default web browser.


🎯 Applications

This project demonstrates the practical integration of Artificial Intelligence and Medical Imaging in several domains, including:

  • AI-Assisted Medical Image Analysis
  • Brain Tumor Classification
  • Explainable Artificial Intelligence (XAI)
  • Medical Imaging Research
  • Computer Vision Applications
  • Educational Demonstration of Deep Learning
  • Clinical Decision Support Research

⚠️ Limitations

Although the model demonstrates promising performance, several limitations remain:

  • Performance depends on the quality of MRI images.
  • Trained on a limited publicly available dataset.
  • Grad-CAM provides visual explanations but not precise tumor segmentation.
  • Intended solely for educational and research purposes.
  • Should not be used as a substitute for professional medical diagnosis.

πŸš€ Future Enhancements

Potential improvements include:

  • Integration of larger clinical datasets
  • Transfer Learning using advanced architectures
  • 3D MRI volume analysis
  • Tumor segmentation using U-Net
  • Multi-modal MRI support
  • Real-time clinical integration
  • Model optimization for faster inference
  • Cloud deployment with scalable APIs

πŸ“š Documentation

The repository also includes supporting project documentation.

docs/
β”œβ”€β”€ Project_Report.pdf
└── Research_Paper.pdf

These documents provide detailed information about the project methodology, implementation, evaluation, and research findings.


πŸ‘₯ Team

Member Contribution
Tanmay Tawade CNN model integration, Streamlit application development, Grad-CAM implementation, system architecture, report generation, and deployment
Aishwarya Kale Dataset preparation, preprocessing, workflow design, documentation, and project validation
Sakshi Bedekar Project planning, testing, performance evaluation, documentation, and presentation

The project was developed collaboratively, with all members contributing to the design, implementation, testing, and evaluation phases.


πŸ™ Acknowledgements

Special thanks to the following resources and communities:

  • Kaggle Brain MRI Dataset
  • TensorFlow & Keras
  • OpenCV
  • Streamlit
  • ReportLab
  • Research community working in Deep Learning and Explainable Artificial Intelligence (XAI)

πŸ‘¨β€πŸ’» Author

Tanmay Tawade

If you found this project helpful or interesting, consider giving it a ⭐ on GitHub.


⭐ If you found this project useful, please consider starring the repository!

Building trustworthy AI requires not only accurate predictions but also transparent and interpretable decision-making.


Made with ❀️ using Python, TensorFlow & Explainable AI by Tanmay Tawade

About

AI-powered brain tumor detection and classification system using CNN and Explainable AI (Grad-CAM). Features MRI preprocessing, confidence analysis, PDF report generation, and an interactive Streamlit web application.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages