Spaces:
Sleeping
Sleeping
| 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* | |