Live Demo β’ Report Bug β’ Request Feature
An intelligent deep learning application that automatically classifies brain tumors from MRI scans into four categories: Glioma, Meningioma, Pituitary Tumor, and No Tumor. Built with state-of-the-art computer vision techniques and deployed as an interactive web application.
- High Accuracy: ResNet18-based architecture fine-tuned for medical image classification
- Explainable AI: Grad-CAM visualization shows which brain regions influenced the prediction
- User-Friendly: Intuitive Streamlit interface requiring no technical expertise
- Flexible Input: Upload local images or provide URLs for instant analysis
- Real-Time: Fast predictions with confidence scores for all tumor types
π Try it now: Brain Tumor Detector Web App
Upload an MRI scan and get instant results with visual explanations!
| Feature | Description |
|---|---|
| π Multi-Class Detection | Classifies 4 tumor types: Glioma, Meningioma, Pituitary, No Tumor |
| π€ Flexible Upload | Support for image upload and URL-based input |
| π¨ Grad-CAM Visualization | Heatmap overlays highlight decision-making regions |
| π Confidence Scores | Probability distribution across all classes |
| β‘ Fast Inference | Real-time predictions with optimized model |
| π± Responsive Design | Works seamlessly on desktop and mobile devices |
- Base Architecture: ResNet18 (Transfer Learning)
- Framework: PyTorch 2.0+
- Input Size: 224Γ224 RGB images
- Output Classes: 4 (Glioma, Meningioma, Pituitary, No Tumor)
- Explainability: Grad-CAM visualization on final convolutional layer
Frontend: Streamlit
Backend: PyTorch, OpenCV
Deployment: Streamlit Cloud
- Source: Kaggle Brain MRI Images Dataset
- Classes: 4 balanced categories
- Preprocessing: Resizing, normalization, augmentation
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/Yaseen-md/Brain-Tumor-Detector.git cd Brain-Tumor-Detector -
Create virtual environment (recommended)
python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
streamlit run app.py
-
Open your browser
Navigate to http://localhost:8501
Brain-Tumor-Detector/
βββ app.py # Streamlit web application
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
βββ models/
β βββ resnet18_best.pth # Trained model weights
β βββ loss_history.npy # Training metrics
β βββ y_pred.npy # Validation predictions
β βββ y_true.npy # Ground truth labels
βββ src/
β βββ model.py # Model architecture
β βββ train.py # Training script
β βββ evaluate.py # Evaluation utilities
β βββ inference.py # Prediction functions
β βββ grad_cam.py # Grad-CAM implementation
β βββ data_loader.py # Dataset handling
β βββ utils.py # Helper functions
β βββ validate_dataset.py # Data validation
βββ notebooks/
βββ 01_data_exploration.ipynb # EDA
βββ 02_model_training.ipynb # Training experiments
βββ 03_model_evaluation.ipynb # Performance analysis
βββ 04_grad_cam_visualization.ipynb # Visualization demos
| Metric | Score |
|---|---|
| Training Accuracy | High |
| Validation Accuracy | Competitive |
| Inference Time | < 1 second |
Detailed metrics available in notebooks/03_model_evaluation.ipynb
- Visit the live demo
- Upload an MRI scan or paste an image URL
- Click "Predict"
- View results with Grad-CAM visualization
from src.inference import predict_image
from src.utils import load_model
model = load_model('models/resnet18_best.pth')
prediction = predict_image(model, 'path/to/mri.jpg')
print(f"Prediction: {prediction['class']}")
print(f"Confidence: {prediction['confidence']:.2%}")- β Deploy to Streamlit Cloud
- π Implement ensemble models for improved accuracy
- π Add model performance dashboard
- π₯ Support for video/DICOM file uploads
- π Generate downloadable PDF reports
- π Multi-language support
- π Add user authentication and history tracking
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT License. See LICENSE for more information.
- Dataset: Navoneel Chakrabarty - Brain MRI Images
- Frameworks: PyTorch | Streamlit
- Architecture: ResNet18 from torchvision.models
- Grad-CAM: Implementation based on Grad-CAM paper
Yaseen MD
- GitHub: @Yaseen-md
- Project Link: Brain-Tumor-Detector
Found this helpful? Give it a βοΈ to show your support!
Made with β€οΈ and π§ by Yaseen