Skip to content

Raghu20git/Brain-Tumor-Detection-and-Classification-Using-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brain Tumor Detection & Classification Using CNN

Overview

This project implements an AI-based system for brain tumor classification from MRI images using deep learning. The pipeline performs model inference, uncertainty estimation, explainability (Grad-CAM & Grad-CAM++), and automatic clinical-style PDF report generation.

The system is designed for research and educational purposes only and is not intended for clinical diagnosis.

Key Features

  • EfficientNet-B0 based MRI classifier
  • Multi-class tumor detection (4 classes)
  • Monte Carlo Dropout uncertainty estimation
  • Grad-CAM and Grad-CAM++ visual explanations
  • Automatic AI case report (PDF)
  • GPU acceleration support (CUDA)
  • Modular and reproducible pipeline

Datasets

Methodology (Transfer Learning)

  • Data cleaning performed to remove corrupted, duplicate, and blank MRI images
  • Images resized to 224×224, normalized, and converted to tensors during preprocessing
  • Applied data augmentation (random flip, rotation, color jitter) to improve generalization
  • Used pretrained EfficientNet-B0 as the backbone for transfer learning
  • Replaced the original classification head (the final classification layer) with a new 4-class (4 tumor classes) fully connected layer
  • Initially froze all backbone layers and trained only the new classification layer
  • Subsequently unfroze the backbone layers and fine-tuned the entire network
  • Optimized the model using AdamW with low learning rate and weight decay
  • Evaluated performance using accuracy, precision, recall, F1-score, confusion matrix, and ROC-AUC
  • Generated visual explanations using Grad-CAM and Grad-CAM++ for interpretability
  • Estimated prediction uncertainty using Monte Carlo Dropout during inference
  • Saved best and last model checkpoints for reproducibility

Results

Best Validation Accuracy

Best Validation Accuracy

Final Test Accuracy

Final Test Accuracy

Confusion Matrix

Confusion Matrix

Classification Report

Classification Report

Macro ROC-AUC

Macro ROC-AUC

Grad-CAM Output

GradCAM Output

Grad-CAM and Grad-CAM++ Overlay

Grad-CAM and GradCAM++ Overlay

PDF generated for a random test image

Generated PDF

Project Structure

Brain Tumor Detection & Classification Using CNN/ │ ├── .vscode │ └── settings.json ├── AI_Reports ├── Checkpoints ├── Dataset/ │ ├── Testing │ └── Training ├── Results ├── .gitignore ├── main.ipynb ├── README.md └── requirements.txt

Environment Setup

1. Create virtual environment (Python 3.10.11 recommended)

Run "py -3.10 -m venv venv" in the Powershell (Open the Powershell in the project folder)

2. Activate

Run ".\venv\Scripts\Activate" in the Powershell (Open the Powershell in the project folder)

3. Do NOT rely on requirements.txt to install torch, torchvision & torchaudio if you want to use NVIDIA GPU (CUDA supported).

Instead do: Step 1 — install CUDA PyTorch manually by running "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121" in the Powershell (Open the Powershell in the project folder) Step 2 — install the rest by running "pip install -r requirements.txt" in the Powershell (Open the Powershell in the project folder)

4. Default (Works Everywhere):

Step 1 — Run "pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu" in the Powershell (Open the Powershell in the project folder) Step 2 — Run "pip install -r requirements.txt" in the Powershell (Open the Powershell in the project folder)

5. Register Jupyter kernel:

Run "python -m ipykernel install --user --name brain_tumor_py310 --display-name "Python 3.10 (BrainTumor)" in the Powershell (Open the Powershell in the project folder)

About

Developed an AI-based brain tumor classification system from MRI using transfer learning with EfficientNet-B0, integrated with Monte Carlo Dropout uncertainty estimation, Grad-CAM explainability, and automated clinical report generation.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors