This repository contains the implementation of a deep learning model designed for brain tumor detection using Magnetic Resonance Imaging (MRI) scans. The model utilizes Class Activation Maps (CAM) to provide interpretable insights and guide channel attention, enabling accurate and explainable predictions.
- Binary Classification: Tumor vs. No Tumor.
- Interpretable Predictions: CAM visualizations highlight critical regions in MRI scans for model decisions.
- Dataset Preprocessing: Cropping, resizing, and normalization techniques are used to enhance model performance.
- Attention Mechanism: CAM-guided attention improves feature extraction and model generalization.
- Dataset
- Model Architecture
- Training Pipeline
- Results and Visualizations
- How to Use
- Future Work
- Acknowledgments
The model was trained and evaluated using a dataset of 2,065 MRI images (after augmentation) sourced from:
- Cropping: Removes irrelevant background information.
- Resizing: Standardizes all images to a fixed size of
240x240
. - Normalization: Scales pixel values to [0, 1] for numerical stability.
- Augmentation: Increases dataset size to improve model generalization.
Layer | Details | Output Shape |
---|---|---|
Input | MRI image (3 channels, 240x240) | (3, 240, 240) |
Conv2D | 32 filters, kernel size=5, stride=1, padding=2 | (32, 240, 240) |
BatchNorm2D | Batch normalization on 32 channels | (32, 240, 240) |
ReLU Activation | Introduces non-linearity | (32, 240, 240) |
MaxPool2D | Kernel size=4, stride=4 | (32, 60, 60) |
CAM-Guided Attention | Refines feature maps | (32, 60, 60) |
MaxPool2D | Kernel size=4, stride=4 | (32, 15, 15) |
Flatten | Converts features into 1D vector | (32 * 15 * 15) |
Fully Connected | Sigmoid activation for binary classification | (1) |
- Optimizer: Adam with a learning rate of
0.001
. - Loss Function: Binary Cross Entropy Loss (BCELoss) for probability-based classification.
- Progressive Attention: CAM-guided attention is introduced after two epochs to stabilize training.
- Metrics Tracked:
- Training Loss
- Validation Loss
- Training Accuracy
- Validation Accuracy
- Validation Accuracy: ~98.12%
- Test Accuracy: ~94.87%
git clone https://github.com/your-username/brain-tumor-detection.git
cd brain-tumor-detection
- Extend to multiclass classification (e.g., distinguishing between benign and malignant tumors).
- Integrate additional interpretability techniques like Grad-CAM++.
- Optimize the model for real-time inference on lightweight devices.
- CAM Research: Inspired by Woo et al., 2018.
- Dataset Contributors: Kaggle community for publicly available MRI datasets.