This project focuses on detecting brain tumors from MRI scans using a Convolutional Neural Network (CNN). To make the model predictions more transparent and interpretable, we integrate Explainable AI (XAI) tools such as:
- 🔍 SHAP (SHapley Additive Explanations)
- 🧩 LIME (Local Interpretable Model-Agnostic Explanations)
- 🔥 Grad-CAM (Gradient-weighted Class Activation Mapping)
To benchmark performance, we also compare the CNN model against a Vision Transformer (ViT) architecture. All experiments are run on Google Colab, utilizing GPU for fast training.
- 🎯 High-accuracy brain tumor classification using CNN
- 🧠 Interpretability via SHAP, LIME, and Grad-CAM
- 📊 Model comparison with Vision Transformer
- 📸 Visual outputs for prediction and explanation
- ☁️ 100% compatible with Google Colab
- Built using Keras
- Includes Conv2D, MaxPooling, Flatten, Dense, Dropout layers
- Classifies MRI images as
Tumor
orNo Tumor
- Transformer-based image classification model
- Operates on image patches instead of convolutions
- Used for performance comparison with CNN
Method | Purpose | Output |
---|---|---|
SHAP | Global + local feature importance | Value-based overlays |
LIME | Local explanation using superpixels | Segmented masks |
Grad-CAM | Highlights most important image regions | CNN-based heatmaps |
Model | Accuracy | Precision | Recall | F1-Score |
---|---|---|---|---|
CNN (Baseline) | 98.5% | 98.7% | 98.4% | 98.5% |
CNN + SHAP | 98.5% | 98.7% | 98.4% | 98.5% |
CNN + LIME | 98.5% | 98.6% | 98.3% | 98.4% |
CNN + Grad-CAM | 98.5% | 98.8% | 98.4% | 98.6% |
Vision Transformer | 97.2% | 97.4% | 97.0% | 97.2% |
Tool | Pros | Cons |
---|---|---|
SHAP | Pixel-level importance, model-agnostic | Slower with large images |
LIME | Simple visual output, works with any model | Inconsistent with different segmentations |
Grad-CAM | Effective for CNN heatmaps | Not compatible with ViT |
✅ Conclusion: The CNN + Grad-CAM combination provided the most interpretable and accurate results.
- Name: Brain MRI Images for Brain Tumor Detection
- Source: Kaggle
- Classes: Tumor, No Tumor
- Preprocessing:
- Image resizing to uniform shape
- Normalization
- One-hot encoding of labels
- Open Google Colab
- Mount Google Drive or upload dataset directly
- Run the following notebooks in order:
BrainTumorDetection_CNN.ipynb
shap_explanation.ipynb
lime_explanation.ipynb
gradcam_explanation.ipynb
ViT_Comparison.ipynb
- View performance metrics and explanation visualizations in the output cells.
Most packages are pre-installed in Google Colab. For local use:
pip install tensorflow keras numpy matplotlib opencv-python shap lime