A deep learning web application that classifies brain MRI scans into 4 tumor categories using EfficientNetB0 with transfer learning. Deployed on Hugging Face Spaces via Docker.
Upload any brain MRI scan and get an instant prediction with confidence scores for all 4 classes.
| Metric | Score |
|---|---|
| Test Accuracy | 87.00% |
| Precision (weighted) | 87.30% |
| Recall (weighted) | 87.00% |
| F1 Score (weighted) | 86.60% |
| Class | Precision | Recall | F1 Score | Support |
|---|---|---|---|---|
| Glioma | 93% | 72% | 81% | 400 |
| Meningioma | 82% | 78% | 80% | 400 |
| No Tumor | 86% | 99% | 92% | 400 |
| Pituitary | 87% | 99% | 93% | 400 |
Brain Tumor MRI Dataset by Masoud Nickparvar
| Split | Images |
|---|---|
| Training | 5,712 |
| Testing | 1,600 |
| Total | 7,023 |
4 classes: Glioma · Meningioma · No Tumor · Pituitary
EfficientNetB0 (ImageNet weights, frozen)
└── GlobalAveragePooling2D
└── BatchNormalization
└── Dense(256, relu)
└── Dropout(0.4)
└── Dense(128, relu)
└── Dropout(0.3)
└── Dense(4, softmax)
Training strategy:
- Phase 1 — Frozen base, 10 epochs, lr=1e-3
- Phase 2 — Fine-tune last 30 layers, 8 epochs, lr=1e-5
- EarlyStopping + ReduceLROnPlateau callbacks
- No manual rescaling (EfficientNetB0 handles normalization internally)
Deployed on Hugging Face Spaces using Docker.
app.py # Flask backend
templates/index.html # Frontend UI
brain_tumor_classifier.h5 # Trained model (hosted on HF Spaces)
Dockerfile # Docker configuration
requirements.txt # Python dependencies
Note: The model file (
brain_tumor_classifier.h5, ~32MB) is hosted on Hugging Face Spaces via Git LFS and is not included in this GitHub repository.
git clone https://github.com/AhadAhmad0/Brain_Tumour_Classification_Project
cd Brain_Tumour_Classification_Project
pip install -r requirements.txt
# Download model from Hugging Face and place in project root
# https://huggingface.co/spaces/AhadAhmad0/Brain-Tumor-Classification
python app.py| Component | Technology |
|---|---|
| Model | EfficientNetB0 (Transfer Learning) |
| Framework | TensorFlow 2.19 / Keras 3.13 |
| Backend | Flask 2.3 |
| Frontend | HTML, CSS, JavaScript |
| Deployment | Docker + Hugging Face Spaces |
| Training | Kaggle (GPU T4 x2) |
This tool is for educational and research purposes only. It is not a medical device and should not be used for clinical diagnosis.
Ahad Ahmad
- GitHub: @AhadAhmad0
- Email: ahadahmad0701@gmail.com