Advanced deep learning platform for automated brain tumor detection and classification from MRI scans.
π― 84.13% Classification Accuracy | π < 3 Second Analysis | π¬ 4 Tumor Types Detected
- High-Accuracy Detection: 84.13% accuracy using ResNet50V2 architecture
- Multi-Class Classification: Detects Glioma, Meningioma, Pituitary tumors, and normal scans
- Visual Segmentation: U-Net based tumor region highlighting with overlay
- Lightning Fast: Results in under 3 seconds
- Modern UI: Pinterest-inspired clean aesthetic design
- REST API: Easy integration for developers
| Type | Description | Characteristics |
|---|---|---|
| Glioma | Malignant tumor from glial cells | Aggressive, requires multi-modal treatment |
| Meningioma | Usually benign, from brain protective layers | 90% non-cancerous, surgical treatment |
| Pituitary | Benign adenoma of pituitary gland | Affects hormones, medication/surgery |
| No Tumor | Normal healthy brain scan | No abnormal growths detected |
# System Requirements
- Python 3.10+
- Node.js 18+
- 8GB+ RAM
- GPU optional (for training)# 1. Clone repository
git clone https://github.com/yourusername/neurodl.git
cd neurodl
# 2. Create virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Place models in models/ directory
# - ResNet50V2.keras
# - seg_model2.keras
# 5. Start Flask server
python app.pyServer runs at http://localhost:5001
# 1. Navigate to frontend
cd frontend
# 2. Install dependencies
npm install
# 3. Create .env.local
echo "NEXT_PUBLIC_API_URL=http://localhost:5001" > .env.local
# 4. Start development server
npm run devApp runs at http://localhost:3000
| Model | Accuracy | F1-Score | Parameters | Training Time |
|---|---|---|---|---|
| ResNet50V2 | 84.13% | 0.841 | 23.6M | 2-3 hours |
| Custom CNN | 93.20% | 0.925 | 15.2M | 3-4 hours |
| Meta Model | 98.78% | 0.988 | 0.5M | 10 minutes |
| Class | Precision | Recall | F1-Score |
|---|---|---|---|
| Glioma | 0.85 | 0.83 | 0.84 |
| Meningioma | 0.84 | 0.86 | 0.85 |
| No Tumor | 0.83 | 0.84 | 0.84 |
| Pituitary | 0.85 | 0.84 | 0.85 |
βββββββββββββββ
β MRI Input β
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββββββ
β Preprocessing β
β (224Γ224) β
ββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββ
β ResNet50V2 β
β Classification β
ββββββββ¬βββββββββββ
β
ββββ No Tumor βββββββββββΊ Result
β
ββββ Tumor Detected
β
βΌ
ββββββββββββββββ
β U-Net β
β Segmentationβ
ββββββββ¬ββββββββ
β
βΌ
ββββββββββββββββ
β Overlay β
β Generation β
ββββββββ¬ββββββββ
β
βΌ
Final Result
Backend
- Python 3.10
- TensorFlow/Keras
- Flask + Flask-CORS
- NumPy, Pillow, scikit-image
Frontend
- Next.js 14 (App Router)
- React 18
- Tailwind CSS
- Chakra UI (Toasts)
ML Models
- ResNet50V2 (Transfer Learning)
- U-Net (Segmentation)
- Custom CNN
- Meta-Model (Ensemble)
neurodl/
βββ app.py # Flask API
βββ requirements.txt # Python dependencies
βββ models/ # Trained models
β βββ ResNet50V2.keras
β βββ seg_model2.keras
βββ src/ # Source code
β βββ config.py # Configuration
β βββ preprocess.py # Image preprocessing
β βββ inference.py # Model inference
β βββ utils.py # Utilities
βββ data/ # Dataset
β βββ raw_dataset/
β βββ sample/
βββ notebooks/ # Jupyter notebooks
β βββ classification_ResNet50.ipynb
β βββ segmentation_model.ipynb
β βββ ...
βββ frontend/ # Next.js app
β βββ src/
β β βββ app/
β β βββ components/
β β βββ page.js
β β βββ layout.js
β β βββ globals.css
β βββ package.json
β βββ next.config.js
βββ training_outputs/ # Training results
Health check endpoint
Response:
{
"status": "online",
"service": "NeuroDL Brain Tumor Detection API",
"version": "1.0.0",
"model": "ResNet50V2",
"accuracy": "84.13%"
}Analyze MRI scan
Request:
curl -X POST http://localhost:5001/predict \
-F "image=@scan.jpg"Response:
{
"final_class": 1,
"class_name": "Meningioma Tumor",
"confidence": "92.45%",
"model_used": "ResNet50V2",
"model_accuracy": "84.13%",
"segmentation_performed": true,
"segment_image": "base64_encoded_image_string"
}/* Primary Colors */
--color-primary: #E60023 /* Pinterest Red */
--color-secondary: #000000 /* Black */
/* Backgrounds */
--color-bg-primary: #FFFFFF /* White */
--color-bg-secondary: #F7F7F7 /* Light Gray */
--color-footer: rgb(51, 51, 45) /* Dark Gray */
/* Text */
--color-text-primary: #000000 /* Black */
--color-text-secondary: #5F5F5F /* Gray */- Font: System fonts (-apple-system, Segoe UI, Roboto)
- Headings: Bold, letter-spacing -0.02em
- Body: 1.125rem, line-height 1.7
- Total Images: 34,000+ MRI scans
- Training: 70% (23,800 images)
- Validation: 15% (5,100 images)
- Testing: 15% (5,100 images)
- Classes: 4 (balanced distribution)
- Format: JPG, PNG (variable resolution)
- Preprocessing: Resize to 224Γ224, normalize to [0,1]
# Prepare dataset structure
data/
βββ raw_dataset/
βββ Training/
β βββ glioma_tumor/
β βββ meningioma_tumor/
β βββ pituitary_tumor/
β βββ no_tumor/
βββ Testing/
βββ [same structure]
# Run training
python train_all_models.py
# Evaluate models
python evaluate_models.py# Classification
IMAGE_SIZE = 128
BATCH_SIZE = 32
EPOCHS = 30
OPTIMIZER = Adam(lr=0.001)
LOSS = SparseCategoricalCrossentropy
# Segmentation
IMAGE_SIZE = 256
BATCH_SIZE = 8
EPOCHS = 100
OPTIMIZER = Adam(lr=0.00005)
LOSS = DiceLoss# Backend Dockerfile
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5001
CMD ["python", "app.py"]# Frontend Dockerfile
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]# Install Vercel CLI
npm i -g vercel
# Deploy
cd frontend
vercel
# Set environment variable
NEXT_PUBLIC_API_URL=https://your-api-url.com- Connect GitHub repository
- Set start command:
python app.py - Add environment variables
- Deploy
# Model paths
RESNET50_MODEL_PATH = 'models/ResNet50V2.keras'
SEGMENTATION_MODEL_PATH = 'models/seg_model2.keras'
# Image sizes
CLASSIFICATION_IMAGE_SIZE = (224, 224)
SEGMENTATION_IMAGE_SIZE = (256, 256)
# Processing
BATCH_SIZE = 32NEXT_PUBLIC_API_URL=http://localhost:5001# Health check
curl http://localhost:5001/
# Prediction
curl -X POST http://localhost:5001/predict \
-F "image=@test_scan.jpg"python evaluate_models.pyOutput:
- Accuracy metrics
- Confusion matrix
- Per-class performance
- Visualizations in
training_outputs/
This application is for research and educational purposes only.
- β Not FDA approved
- β Not for clinical diagnosis
- β Not a substitute for professional medical advice
- β Always consult qualified healthcare professionals
- β Verify AI predictions with medical experts
- Main README: This file
- Frontend:
frontend/README.md - Dataset:
data/Readme.md - Notebooks:
notebooks/Readme.md - API Docs: See API Reference section above
Contributions welcome! Please follow these steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
Guidelines:
- Follow existing code style
- Add tests for new features
- Update documentation
- Ensure responsive design (frontend)
This project is licensed under the MIT License.
MIT License
Copyright (c) 2024 NeuroDL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Dataset: Brain MRI Images for Brain Tumor Detection
- Base Model: ResNet50V2 (ImageNet pre-training)
- Framework: TensorFlow/Keras
- UI Inspiration: Pinterest design system
- Community: Open source contributors
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: your-email@example.com
Built with β€οΈ for advancing AI in healthcare
NeuroDL - Making brain tumor detection accessible through artificial intelligence