An end-to-end deep learning computer vision pipeline designed to automate the multi-class detection, segmentation, and classification of brain tumors from multi-modal MRI scans.
The core architecture utilizes a custom Convolutional Neural Network (CNN) engineered for high-fidelity classification, integrated with Explainable AI (Grad-CAM) to map, audit, and validate highly influential diagnostic regions for clinical stakeholders and medical professionals.
- Multi-Class Differential Diagnostics: Classifies raw MRI slices into four distinct clinical categories:
- Healthy Tissue (Non-Tumor)
- Glioma
- Meningioma
- Pituitary Tumors
- Advanced Medical Image Preprocessing: Standardizes raw DICOM/PNG matrices to optimize feature extraction using:
- Contrast Stretching & Histogram Equalization for structural boundary definition.
- Otsu's Thresholding & Skull-Stripping to isolate the cerebral parenchyma from non-brain anatomy.
- Gaussian Filtering for high-frequency noise mitigation.
- Explainable AI (Grad-CAM Integration): Overlays visual heatmaps on the final convolutional layer's gradients. This localizes the spatial regions driving the model's classifications, ensuring algorithmic transparency.
- Robust Data Augmentation: Implements strategic geometric transforms (controlled rotations, scaling, and shearing) to alleviate clinical class imbalances and mitigate model overfitting.
- Core Programming: Python
- Deep Learning Framework: TensorFlow / Keras
- Computer Vision & Matrix Math: OpenCV, NumPy, pandas
- Data Visualization & Analytics: Matplotlib, Seaborn, Scikit-learn
The pipeline leverages a custom, optimized CNN architecture featuring:
- Alternating Convolutional Blocks with scaled filter depths (32 to 256 keys) to capture both low-level spatial edges and high-level abstract pathological patterns.
- Max-Pooling Layers for spatial dimensionality reduction.
- Dropout Regularization (0.3 - 0.5) and Batch Normalization to guarantee structural robustness and faster convergence.
- Softmax Classification Head computing multi-class categorical probabilities.
- Loss Function: Categorical Cross-Entropy
- Optimizer: Adam (with dynamic learning rate scheduling via
ReduceLROnPlateau) - Batch Size: 32 (optimized for memory bandwidth and gradient stability)
The network achieved a peak overall classification accuracy of 95% on the validation partition.
| Metric | Healthy | Glioma | Meningioma | Pituitary | Overall |
|---|---|---|---|---|---|
| Accuracy | — | — | — | — | 95.0% |
| F1-Score | 0.96 | 0.93 | 0.94 | 0.97 | 0.95 |
- Confusion Matrix: Demonstrates strong sensitivity boundaries between structurally similar tumor profiles (e.g., Glioma vs. Meningioma).
- ROC-AUC Curves: Validates true-positive vs. false-positive rates across varying operational thresholds.
- Grad-CAM Visual Audits: Generates side-by-side comparisons of the original scan, the target activation map, and the blended clinical heatmap.
├── Brain_model/
│ ├── data_pipeline.py # Custom DICOM/Image ingestion and preprocessing
│ ├── model_architecture.py # TensorFlow/Keras custom CNN network structure
│ ├── train.py # Training configuration, callbacks, and loops
│ └── explainability.py # Grad-CAM matrix calculations and visual overlay
├── visualizations/
│ ├── confusion_matrix.png # Model performance matrix
│ ├── training_history.png # Loss/Accuracy convergence plots
│ └── grad_cam_samples/ # Visual explanations of model clinical inference
├── results/
│ └── metrics_report.txt # Precision, recall, and F1-score outputs
├── LICENSE # Apache-2.0 open-science license
└── README.md # Project documentation
git clone https://github.com
cd Brain_Tumor_detection_Modelpip install -r requirements.txtpython Brain_model/explainability.py --image_path path/to/mri_slice.pngDistributed under the Apache-2.0 License. See LICENSE for more information.