Asad-Aziz-001/Brain-Tumor-Detection
A web app to detect brain tumors from MRI images using YOLOv8 and visualize predictions with bounding boxes and semi-transparent masks. Built with Python, OpenCV, and Streamlit.
๐ง Brain Tumor Detection using YOLOv8
A powerful web application for detecting brain tumors in MRI scans using state-of-the-art YOLOv8 deep learning model
๐ Overview
Brain Tumor Detection is an intelligent web application that leverages the power of YOLOv8 (You Only Look Once) to automatically detect and localize brain tumors in MRI images. This tool provides medical professionals and researchers with an accessible interface for rapid preliminary analysis of brain MRI scans.
๐ฏ Key Features
- ๐ Accurate Detection: Powered by YOLOv8 for precise tumor localization
- ๐จ Visual Annotations: Bounding boxes with semi-transparent masks
- ๐ Confidence Scoring: Real-time prediction confidence levels
- ๐ Web Interface: User-friendly Streamlit-based web app
- โก Real-time Processing: Instant analysis with visual feedback
- ๐ฑ Responsive Design: Works seamlessly on different devices
๐ Quick Start
Prerequisites
- Python 3.10+
- pip package manager
Installation
-
Clone the repository
git clone https://github.com/your-username/brain-tumor-detection.git cd brain-tumor-detection -
Create virtual environment (Recommended)
python -m venv venv # Linux/Mac source venv/bin/activate # Windows venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Download the YOLO model
- Place your trained
brain_tumor_detection.ptfile in the project root directory
- Place your trained
Running the Application
streamlit run main.pyOpen your browser and navigate to http://localhost:8501 to access the application.
๐ Project Structure
brain-tumor-detection/
โโโ main.py # Main Streamlit application
โโโ brain_tumor_detection.pt # YOLOv8 trained model (not included)
โโโ requirements.txt # Python dependencies
โโโ runtime.txt # Python version specification
โโโ packages.txt # System dependencies
โโโ .streamlit/
โ โโโ config.toml # Streamlit configuration
โโโ README.md # Project documentation
๐ ๏ธ Technical Details
Model Architecture
This application uses YOLOv8 (You Only Look Once version 8), which provides:
- Real-time object detection capabilities
- High accuracy in medical image analysis
- Efficient processing with optimized neural network architecture
Detection Process
- Image Preprocessing: MRI images are normalized and prepared for inference
- YOLOv8 Inference: Model processes the image and identifies potential tumor regions
- Post-processing: Non-maximum suppression filters overlapping detections
- Visualization: Bounding boxes and masks are overlaid on the original image
Supported Formats
- Image Formats: JPG, JPEG, PNG
- MRI Types: T1-weighted, T2-weighted, FLAIR sequences
๐ป Usage Guide
Step-by-Step Process
-
Launch the Application
- Run
streamlit run main.py - The web interface will open automatically
- Run
-
Upload MRI Image
- Click "Upload MRI Image" button
- Select your brain MRI scan from your device
-
View Results
- Original image displays on the left
- Annotated results show on the right with:
- Bounding boxes around detected regions
- Color-coded masks highlighting tumor areas
- Confidence scores for each detection
- Classification labels ("Tumor" or "Normal")
Interpretation of Results
- ๐ด Red Boxes: High-confidence tumor detections
- ๐ Orange Boxes: Other abnormalities or lower-confidence findings
- Confidence Score: Percentage indicating detection certainty (0-100%)
- Mask Overlay: Semi-transparent colored regions highlighting affected areas
๐๏ธ Deployment
Local Deployment
Follow the installation steps above for local deployment.
Cloud Deployment (Streamlit Cloud)
- Fork this repository
- Visit Streamlit Cloud
- Connect your GitHub account
- Deploy the app by selecting your forked repository
- Ensure all required files are present in the repository
๐ Model Performance
The YOLOv8 model used in this application has been trained on diverse MRI datasets and demonstrates:
- High Precision: Accurate tumor localization
- Fast Inference: Real-time processing capabilities
- Robust Performance: Consistent across different MRI machines and protocols
๐ง Configuration
Customizing Detection Parameters
Modify the following in main.py for different use cases:
# Confidence threshold (0-1)
conf_threshold = 0.25
# IoU threshold for non-maximum suppression
iou_threshold = 0.45
# Detection classes
class_names = {0: "Tumor", 1: "Normal"}๐ค Contributing
We welcome contributions from the community! Here's how you can help:
- Report Issues: Found a bug? Create an issue with detailed information
- Feature Requests: Suggest new features or improvements
- Code Contributions: Submit pull requests for bug fixes or enhancements
- Documentation: Help improve documentation and examples
Development Setup
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a pull request
โ ๏ธ Important Disclaimer
Medical Disclaimer: This application is intended for research and educational purposes only. It should not be used as a substitute for professional medical diagnosis, advice, or treatment. Always consult qualified healthcare professionals for medical concerns.
- This tool provides preliminary analysis only
- Not FDA-approved for clinical use
- Results should be verified by medical professionals
- Use at your own risk
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Ultralytics for the YOLOv8 framework
- Streamlit for the amazing web app framework
- OpenCV for computer vision capabilities
- PyTorch for deep learning infrastructure
- The medical imaging research community for continuous advancements
๐ Support
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Provide relevant error logs and system information
Made with โค๏ธ for the medical research community
Contributions welcome! Help us make medical AI more accessible.
[โญ Star this repo] โข [๐ Report Issues] โข [๐ก Suggest Features]