Brain Tumor Detection System using YOLOv8 AI-powered brain tumor detection system that uses YOLOv8 object detection to accurately identify and localize tumors in MRI images. The system supports real-time inference, image upload, result storage, and AI-generated medical explanations.
Features
✅ Brain tumor detection using YOLOv8
✅ MRI image upload support
✅ Real-time live detection
✅ Bounding box tumor localization
✅ Confidence score display
✅ SQLite database for storing detection history
✅ AI-generated tumor explanation (Gemini API)
✅ Web-based user interface
✅ CPU & GPU inference support
🏗️ System Architecture
User Interface → FastAPI Backend → YOLOv8 Inference → SQLite Database → Gemini AI → Results Display
📂 Project Structure Brain-Tumor-Detection/ │ ├── dataset/ # MRI dataset (YOLO format) ├── models/ # Trained YOLOv8 model weights ├── static/ # CSS, JS, images ├── templates/ # HTML files ├── app.py # FastAPI main application ├── database.db # SQLite database ├── requirements.txt # Dependencies └── README.md
🧠 Model Details
Model: YOLOv8n
Input Size: 640 × 640
Dataset Split:
70% Training
20% Validation
10% Testing
Evaluation Metrics:
Precision
Recall
mAP@0.5
mAP@0.5–0.95
📊 Dataset
Brain MRI dataset sourced from:
Roboflow
TCIA / BRATS (if applicable)
Preprocessing:
Auto-orientation
Resize to 640×640
YOLO annotation format conversion
🖥️ Installation 1️⃣ Clone Repository git clone https://github.com/Yashas0128/brain-tumor-detection.git cd brain-tumor-detection
2️⃣ Create Virtual Environment (Optional) python -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows
3️⃣ Install Dependencies pip install -r requirements.txt
Open in browser:
📸 Usage
Upload an MRI image
Click Analyze Image
View tumor detection with confidence score
Check detection history in the dashboard
📦 Requirements
Python 3.8+
PyTorch
Ultralytics YOLOv8
FastAPI
OpenCV
SQLite
NumPy
Pandas
This system is designed as an AI-assisted diagnostic support tool and does not replace professional medical diagnosis. Always consult qualified healthcare professionals.
🔮 Future Improvements
Multi-class tumor classification
Tumor segmentation (Mask-based)
Larger clinical dataset validation
Cloud deployment
Improved real-time performance