https://github.com/stonewerner/brain-tumor-ml
ML model to identify types of brain tumors in MRI scans.
https://github.com/stonewerner/brain-tumor-ml
ai gemini ml python streamlit
Last synced: about 2 months ago
JSON representation
ML model to identify types of brain tumors in MRI scans.
- Host: GitHub
- URL: https://github.com/stonewerner/brain-tumor-ml
- Owner: stonewerner
- Created: 2024-11-06T21:56:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-08T14:28:14.000Z (over 1 year ago)
- Last Synced: 2025-02-20T03:42:37.090Z (over 1 year ago)
- Topics: ai, gemini, ml, python, streamlit
- Language: Jupyter Notebook
- Homepage: https://brain-tumor-ml-stone.streamlit.app/
- Size: 4.95 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🧠 Brain Tumor MRI Classification
[](https://www.python.org/)
[](https://www.tensorflow.org/)
[](https://streamlit.io/)
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:
1. **Transfer Learning with Xception**: Leveraging a pre-trained model for enhanced accuracy
2. **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
```bash
# 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
```bash
streamlit run app.py
```
## 🖥️ Web Interface Features
1. **Image Upload**: Support for jpg, jpeg, and png formats
2. **Model Selection**: Choose between Transfer Learning and Custom CNN
3. **Visualization**:
- Original MRI scan
- Saliency map highlighting model focus areas
4. **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
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## 📧 Contact
Stone Werner - stonewerner.com
Project Link: [https://github.com/stonewerner/brain-tumor-ML](https://github.com/stonewerner/brain-tumor-ML)