SSL-Former / README.md
saifulislamoni's picture
Deploy: Brain Tumor Classifier with GradCAM and PDF reports - MoCo SSL + Swin-Transformer
c703689
---
title: Brain Tumor Classifier
emoji: 🧠
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
---
# 🧠 Brain Tumor Classification AI
**AI-powered MRI analysis for brain tumor detection and classification**
Using MoCo Self-Supervised Learning with Swin-Transformer backbone for high-accuracy tumor classification.
---
## ✨ Features
- 🎯 **High Accuracy**: ~95% on test dataset
- 🧠 **4-Class Classification**: Glioma, Meningioma, No Tumor, Pituitary
- πŸ“Š **GradCAM Visualization**: See which regions influenced the prediction
- πŸ“„ **PDF Reports**: Download professional analysis reports
- πŸ“± **Responsive Design**: Works on desktop, tablet, and mobile
---
## πŸš€ Quick Start
1. **Upload MRI Image**
- Click upload area or drag & drop
- Formats: JPEG, PNG, BMP, TIFF
- Max size: 16 MB
2. **View Results**
- Classification with confidence score
- Probability distribution for all classes
- GradCAM visualization showing influential regions
3. **Download Report**
- Enter your name
- Get professional PDF report
- Includes all visualizations
---
## πŸ”¬ Model Details
**Architecture:**
- Backbone: Swin-Transformer (ImageNet pre-trained)
- Pre-training: MoCo (Momentum Contrast) - 30 epochs
- Fine-tuning: 2-stage process (30 epochs total)
- Head: Linear classifier (192 β†’ 4 classes)
**Training:**
- Dataset: 17,784 MRI images
- Classes: 4 (balanced)
- Validation: 10% held-out
- Test: 10% locked evaluation
**Performance:**
- Accuracy: ~95%
- Precision: ~95% (weighted)
- Recall: ~95% (weighted)
- F1-Score: ~95% (weighted)
---
## πŸ“Š Class Information
| Class | Description |
|-------|-------------|
| **Glioma** | Aggressive tumor from glial cells |
| **Meningioma** | Tumor from brain membranes |
| **No Tumor** | Healthy brain with no abnormalities |
| **Pituitary** | Tumor in pituitary gland |
---
## πŸŽ“ About GradCAM
The GradCAM (Gradient-weighted Class Activation Map) visualization shows:
- Which regions of the MRI influenced the model's decision
- Warmer colors (red/yellow) = higher importance
- Cooler colors (blue) = lower importance
This helps build trust in AI predictions by showing what the model "looked at" when making its decision.
---
## βš™οΈ Technical Stack
- **Framework**: Flask
- **Deep Learning**: PyTorch
- **Model**: Swin-Transformer
- **Visualization**: GradCAM
- **Reports**: ReportLab
- **Frontend**: HTML5, CSS3, JavaScript
---
## ⏱️ Performance
| Operation | Time |
|-----------|------|
| Model Load | ~10-15s (first time) |
| Classification | ~2-3s |
| GradCAM | Included in classification |
| PDF Report | ~2-3s |
| **Total** | **~15-20s per request** |
---
## πŸ›‘οΈ Data Privacy
- βœ… Images are NOT stored
- βœ… Processed in memory only
- βœ… Temporary files cleaned up
- βœ… No data collection
- βœ… Local processing (no external API calls)
---
## ⚠️ Disclaimer
**This tool is for research and educational purposes only.**
This AI model is NOT a substitute for professional medical diagnosis. All results should be verified by qualified healthcare professionals. Always consult a radiologist or medical doctor for clinical interpretation of MRI scans.
---
## πŸ“š Learn More
- **Paper**: MoCo: Momentum Contrast for Unsupervised Visual Representation Learning
- **Swin-Transformer**: Shifted Windows Transformer for CV
---
## 🀝 Contributing
Feedback and suggestions welcome!
For issues or improvements:
1. Note the problem
2. Share details about the image/results
3. Report via GitHub Issues
---
## πŸ“„ License
Academic use - Research and educational purposes
---
**Created with ❀️ for AI in Medical Imaging**
*Last Updated: 2026-04-20*