A computer vision web application and training pipeline for diagnosing brain tumors from magnetic resonance imaging (MRI) scans.
The system classifies input scans into four diagnostic categories:
- Glioma Tumor
- Meningioma Tumor
- Pituitary Tumor
- No Tumor (Healthy)
main.py: Flask application server providing image upload endpoints, preprocessing routines, model inference, and template rendering.templates/: HTML user interface with responsive CSS for drag-and-drop MRI upload, scan previews, and confidence score displays.notebooks/: Jupyter notebooks for exploratory data analysis (EDA), data augmentation experiments, transfer learning benchmarks, and model evaluation.models.dvc: Data Version Control (DVC) pointer tracking large trained model checkpoint files without bloating the git history.docker/: Dockerfile and deployment configurations for containerized inference.pyproject.toml: Modern Python project specification locked to Python 3.12 and managed with UV.justfile: Standard task runner exposing environment setup, development server launch, and linting commands.
Create the Python 3.12 virtual environment and synchronize all dependencies:
just installStart the Flask web server:
just startOpen your browser and navigate to http://localhost:5000.
To run Flask with hot-reloading and debug output enabled:
just dev-
Preprocessing: Uploaded MRI images are decoded via OpenCV, converted to RGB, resized to the network input resolution (
$128 \times 128$ ), and normalized to the range$[0, 1]$ . - Inference: The processed tensor is passed through the deep convolutional neural network (CNN) feature extractor.
- Classification: Softmax activation calculates posterior probability distributions across the four target diagnostic classes.
- Result Presentation: The UI renders the top-predicted class along with percentage confidence levels.
Model weight files are versioned using DVC to keep the Git repository lightweight. To pull the latest model weights from configured remote storage:
dvc pullYou can build and run the application inside a container:
# Build the Docker image
docker build -f docker/Dockerfile -t brain-tumor-detection .
# Run the container on port 5000
docker run -p 5000:5000 brain-tumor-detection# Check Python syntax and linting
just lint
# Remove cache files and build artifacts
just clean