Spaces:
Runtime error
Runtime error
A newer version of the Gradio SDK is available:
5.13.1
metadata
title: BRAIN_TUMOR_DEDECTOR
app_file: app.py
sdk: gradio
sdk_version: 5.6.0
π§ Brain Tumor MRI Classification
A deep learning project that uses transfer learning and custom CNN architectures to classify brain tumors from MRI scans into four categories: Glioma, Meningioma, Pituitary, and No Tumor.
π― Project Overview
This project implements two different deep learning approaches:
- Transfer Learning with Xception: Leveraging a pre-trained model for enhanced accuracy
- Custom CNN: A dedicated convolutional neural network built from scratch
Both models are deployed through a user-friendly Streamlit web interface that provides:
- Real-time tumor classification
- Confidence scores
- Saliency maps for model interpretability
- AI-generated explanations of the model's focus areas
π Model Architecture & Performance
Transfer Learning Model (Xception)
- Pre-trained on ImageNet dataset
- 36 convolutional layers
- 21 million parameters
- Features:
- Max pooling
- Dropout layers for regularization
- Softmax activation for classification
- Performance metrics:
- High accuracy on test set
- Robust against overfitting
Custom CNN Model
- 4 convolutional layers
- 4.7 million parameters
- Architecture:
- Multiple Conv2D layers with ReLU activation
- MaxPooling2D layers
- Dropout for regularization
- Dense layers with L2 regularization
- Softmax output layer
π οΈ Installation
# Clone the repository
git clone https://github.com/stonewerner/brain-tumor-ML.git
cd brain-tumor-ML
# Install required packages
pip install -r requirements.txt
π¦ Dependencies
- tensorflow >= 2.0
- streamlit
- numpy
- pandas
- pillow
- plotly
- opencv-python
- google-generativeai
- python-dotenv
π Usage
Running the Web App
streamlit run app.py
π₯οΈ Web Interface Features
- Image Upload: Support for jpg, jpeg, and png formats
- Model Selection: Choose between Transfer Learning and Custom CNN
- Visualization:
- Original MRI scan
- Saliency map highlighting model focus areas
- Results Display:
- Predicted tumor type
- Confidence scores
- Interactive probability chart
- AI-generated explanation of the classification
π Data Processing
The project includes robust data handling:
- Image preprocessing and augmentation
- Brightness adjustment for training data
- Proper train/validation/test splits
- Standardized image sizing
π Model Interpretability
- Saliency Maps: Visual explanation of model decisions
- Region Focus: Highlights critical areas in MRI scans
- AI Explanations: Generated using Google's Gemini model
- Confidence Metrics: Probability distribution across classes
π₯ Contributing
- Fork the repository
- 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
π§ Contact
Stone Werner - stonewerner.com
Project Link: https://github.com/stonewerner/brain-tumor-ML