An AI-powered web application that classifies brain MRI scans into four categories: Glioma, Meningioma, Pituitary Tumor, and No Tumor. Features explainable AI with saliency maps and AI-generated explanations.
Click above to test the app with your own MRI images or use our sample images - no installation required!
- 🎯 Multi-Class Classification: Identifies 4 types of brain conditions from MRI scans
- 🤖 Dual Model Architecture: Choose between Custom CNN or Transfer Learning (Xception)
- 🔍 Explainable AI: Saliency maps highlight regions the model focuses on
- 💬 AI-Powered Explanations: Google Gemini generates natural language explanations
- 📊 Confidence Scores: View prediction probabilities for all classes
- 🖼️ Sample Images: Test the app instantly with pre-loaded MRI examples
- ☁️ Cloud Deployed: 24/7 availability on Streamlit Cloud
✅ Predicted: Pituitary Tumor | 📈 Confidence: 99.98% | 🎯 Status: Correct Detection
✅ Predicted: No Tumor | 📈 Confidence: 99.91% | 🎯 Status: Correct Detection
- 4 Convolutional blocks with MaxPooling and Dropout
- L2 regularization for better generalization
- Input: 224×224×3 RGB images
- Output: 4-class softmax predictions
- Pre-trained on ImageNet
- Fine-tuned dense layers for brain tumor classification
- Input: 299×299×3 RGB images
- Achieves high accuracy with fewer training epochs
- Framework: TensorFlow/Keras
- Frontend: Streamlit
- Explainability: Gradient-based saliency maps
- AI Integration: Google Gemini for explanations
- Deployment: Streamlit Cloud + Google Drive (model hosting)
Source: Brain Tumor MRI Dataset (Kaggle)
Classes:
- Glioma
- Meningioma
- No Tumor
- Pituitary
Preprocessing:
- Image rescaling (0-1 normalization)
- Brightness augmentation
- Stratified train/validation/test split
👉 Launch App - No installation required!
-
Clone the repository
git clone https://github.com/AvidThinkerArsum/Brain-Tumor-Classification.git cd Brain-Tumor-Classification -
Install dependencies
pip install -r requirements.txt
-
Set up Google API key (optional, for AI explanations)
echo 'GOOGLE_API_KEY=your_api_key_here' > .env
Get your key from: https://aistudio.google.com/app/apikey
-
Run the app
streamlit run app.py
-
Open your browser
http://localhost:8501
Brain-Tumor-Classification/
├── app.py # Main Streamlit application
├── models/
│ ├── cnn_model.h5 # Custom CNN model (55MB)
│ └── xception_model.weights.h5 # Xception weights (242MB)
├── sample_data/ # Sample MRI images for testing
│ ├── Glioma.png
│ ├── Meningioma.png
│ ├── NoTumor.png
│ └── Pituitary.png
├── static/
│ ├── Results/ # Result screenshots
│ └── saliency_maps/ # Generated saliency visualizations
├── notebooks/
│ └── BrainTumor.ipynb # Training & experimentation notebook
├── requirements.txt # Python dependencies
├── .streamlit/
│ ├── config.toml # App configuration
│ └── secrets.toml.example # Secrets template
└── README.md # This file
- Upload or select a sample brain MRI scan
- Choose between Custom CNN or Xception model
- View predictions with confidence scores
- Analyze saliency maps showing focus regions
- Read AI-generated explanations of the diagnosis
| Model | Accuracy | Precision | Recall |
|---|---|---|---|
| Custom CNN | 80-90% | High | High |
| Xception | 97%+ | Very High | Very High |
Performance varies based on test set and specific tumor types
Contributions are welcome! Feel free to:
- Report bugs
- Suggest features
- Submit pull requests
This project is licensed under the MIT License.
- Dataset: Masoud Nickparvar
- Framework: TensorFlow/Keras
- Deployment: Streamlit Cloud
- AI Integration: Google Gemini
Arsum Nadeem Chaudhary
- GitHub: @AvidThinkerArsum
- Project Link: https://github.com/AvidThinkerArsum/Brain-Tumor-Classification
- Live Demo: https://brain-mri-classification-2024.streamlit.app/
⭐ If you found this project useful, please consider giving it a star!




