Workbrain-tumor-mri-yolov8

Brain Tumor MRI Analysis System

I built an AI-powered medical image analysis system for my thesis.

Role
Full Stack Developer
Timeline
Jan 2026
Main stack
Flask & YOLOv8
Brain Tumor MRI Analysis System — Flask & YOLOv8 project screenshot

Overview

I built an AI-powered medical image analysis system for my thesis. It detects and classifies brain tumors in MRI scans with YOLOv8, from dataset analysis and CPU training to a Flask web app where a user uploads a scan and gets boxes, tumor class and confidence scores back.

The final model reached 93.4% mAP50 on the validation set.

Problem

Reading brain MRI scans by eye is slow, and published research models rarely come as something a person can try. For a thesis I wanted to show that a small detection model can find and name a tumor in a scan, and that the result can sit behind a plain web page anyone can open.

Approach

I built the whole chain myself. Scripts analyse the datasets and train YOLO models, an evaluation script checks the weights, and the best checkpoint is loaded by a Flask app. A user uploads a scan and gets the same image back with boxes, class labels and confidence scores. The model trained on a CPU, and the app runs as a service on my home server.

Outcome

mAP50, validation
93.4%
Precision, validation
92.0%
Recall, validation
86.0%
Tumor classes
3
Images, main dataset
3,064
CPU training time
~27 h

What I built

  • YOLOv8n detector for three tumor types: glioma, meningioma and pituitary
  • Trained on 3,064 labelled MRI images (2,144 train, 612 validation, 308 test) plus a second multimodal tumor dataset of about 4,200 images
  • Training script that fixes dataset paths, supports YOLOv8, YOLOv9 and YOLOv11, and saves a checkpoint every 10 epochs
  • Dataset analysis script for image counts, class balance and a written report
  • Evaluation script for scoring weights on a test set and predicting on single images or folders
  • Flask web app with drag-and-drop upload for JPG, PNG, BMP and TIFF scans up to 16 MB
  • Annotated result image with bounding boxes, class labels and per-detection confidence, plus average, highest and lowest confidence
  • Confusion matrices, precision and recall curves and training result charts for every run
  • Colab and local CPU notebooks, and a service install script so the web app starts on boot and restarts after a crash

Architecture

Thesis pipeline

Diagram: datasets, analysis, training, evaluation and best weights, which feed a Flask web app.
One path from raw scans to a working page. Each step is its own script, so any stage can be rerun alone. Open full size ↗

Datasets

Diagram: a three-class dataset with 3,064 images and a one-class multimodal dataset.
The main set names the tumor type. The multimodal set only asks whether a tumor is present. Open full size ↗

Inference request

Diagram: upload, validate, predict, draw boxes and return a result with confidence scores.
A scan is checked, passed to the model at a 0.25 confidence cut-off, drawn on and returned with its scores. Open full size ↗

Deployment

Diagram: training run and Flask service on the same home server, reached through a subdomain.
Training and serving both happen on my home server. The service restarts itself if it crashes. Open full size ↗

Engineering decisions

  1. 01A small model that runs anywhere

    YOLOv8n is the smallest YOLOv8. It trained on a CPU in about 27 hours and still reached 93.4% mAP50, so no GPU is needed to retrain or to serve it.

  2. 02Detection instead of plain classification

    Boxes show where the model sees the tumor, not just a label. A reader can judge the answer against the scan, which matters for medical images.

  3. 03Report the validation split, say so

    The scores come from the validation images used during training, at the best epoch (96 of 100). A separate test-set score is the next number to add before claiming more.

  4. 04Confidence is shown, never hidden

    Every box carries its score, and the page also shows average, highest and lowest confidence. A low score is visible instead of being rounded into a confident answer.

  5. 05Research tool, not a diagnosis

    The system is a thesis demonstration. It is not a medical device, and its output should never replace a radiologist.

Need something similar?

Tell me what you are building and I will reply within one working day.

Start a project
↑↓ navigate↵ openesc closeCtrl K toggles this menu