Skip to content

Repository files navigation

Brain Tumor Detection System

Python 3.12 Flask TensorFlow Keras PyTorch DVC Docker

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)

Repository Structure

  • 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.

Quick Start Guide

Prerequisites

  • UV (Python package manager)
  • Just (Command runner)

1. Install Dependencies

Create the Python 3.12 virtual environment and synchronize all dependencies:

just install

2. Launch the Application

Start the Flask web server:

just start

Open your browser and navigate to http://localhost:5000.

3. Development Mode

To run Flask with hot-reloading and debug output enabled:

just dev

Model Pipeline & Inference

  1. 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]$.
  2. Inference: The processed tensor is passed through the deep convolutional neural network (CNN) feature extractor.
  3. Classification: Softmax activation calculates posterior probability distributions across the four target diagnostic classes.
  4. Result Presentation: The UI renders the top-predicted class along with percentage confidence levels.

Model Tracking with DVC

Model weight files are versioned using DVC to keep the Git repository lightweight. To pull the latest model weights from configured remote storage:

dvc pull

Docker Deployment

You 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

Code Quality & Maintenance

# Check Python syntax and linting
just lint

# Remove cache files and build artifacts
just clean

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages