Brain Scan AI — YOLO11m-seg Brain Tumor Segmentation
Fine-tuned Ultralytics YOLO11m-seg model for detecting and segmenting brain tumors in MRI slices.
This is the model used by the Brain Scan AI project: https://github.com/shahriar-hd/brain-scan-ai
Medical disclaimer: This model is a research/educational prototype. It is not a medical device and must not be used for clinical diagnosis or treatment decisions.
Model summary
| Property | Value |
|---|---|
| Architecture | YOLO11m-seg (instance segmentation, pretrained yolo11m-seg.pt) |
| Task | Segment + detect (segment) |
| Classes | 0: tumor (single class) |
| Input | RGB image, 256 × 256, normalized to [0, 1] |
| Parameters | 22,336,083 |
| Checkpoint | app/models/yolov11-seg-brain.pt from the Brain Scan AI repository |
| Ultralytics version used for training | 8.3.168 |
| License | AGPL-3.0 (inherited from Ultralytics) |
Training
| Property | Value |
|---|---|
| Dataset | Kaggle 3M Brain MRI Segmentation (TCGA LGG), image/mask pairs |
| Label format | YOLO segmentation polygons, one class (tumor) |
| Split | 80% train / 20% validation |
| Epochs | 100 |
| Image size | 256 × 256 |
| Batch size | 16 |
| Optimizer | Auto (AdamW), LR 0.01 → 0.00004 |
| Augmentation | Default Ultralytics (mosaic, HSV, flips, translate, scale) |
| Hardware | NVIDIA RTX 3050 Ti Laptop GPU (4 GB) |
| Training time | ~5,318 s (~89 min) |
Results
Final validation metrics at epoch 100:
| Metric | Box | Mask |
|---|---|---|
| Precision | 0.879 | 0.883 |
| Recall | 0.823 | 0.777 |
| mAP@0.5 | 0.888 | 0.856 |
| mAP@0.5:0.95 | 0.645 | 0.555 |
Best values observed during training:
| Metric | Epoch | Value |
|---|---|---|
| Box mAP@0.5 | 100 | 0.8877 |
| Mask mAP@0.5 | 81 | 0.8618 |
| Box mAP@0.5:0.95 | 97 | 0.6515 |
| Mask mAP@0.5:0.95 | 96 | 0.5621 |
Per-epoch metrics are available in results.csv and the training curves in training_curves.png.

Sample predictions
| MRI + prediction | MRI + prediction |
|---|---|
![]() | ![]() |
Input images are also included (samples/*-input.jpg). Example 1 is detected with confidence 0.813, example 2 with 0.882.
Files
| File | Description |
|---|---|
yolov11-seg-brain.pt | Original Ultralytics checkpoint (full model + training metadata) |
yolov11-seg-brain.safetensors | Weights-only state_dict in safetensors format, with model metadata |
yolov11-seg-brain.onnx | ONNX export, opset 12, fixed input 1×3×256×256 |
results.csv | All 100 epochs of training/validation metrics |
training_curves.png | Loss and mAP curves |
samples/ | Input MRI slices and annotated predictions |
Usage
Ultralytics (PyTorch)
from ultralytics import YOLO
model = YOLO("yolov11-seg-brain.pt")
results = model.predict("mri.png", imgsz=256, conf=0.5, iou=0.7)
for result in results:
for box, conf, cls in zip(result.boxes.xyxy, result.boxes.conf, result.boxes.cls):
print(model.names[int(cls)], float(conf), box.tolist())
ONNX Runtime (Python)
import cv2
import numpy as np
import onnxruntime as ort
# The model expects a 256x256 RGB tensor in [0, 1], NCHW.
image = cv2.imread("mri.png")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
image = cv2.resize(image, (256, 256))
x = image.astype(np.float32).transpose(2, 0, 1)[None] / 255.0
session = ort.InferenceSession("yolov11-seg-brain.onnx", providers=["CPUExecutionProvider"])
predictions, prototypes = session.run(None, {"images": x})
# predictions: [1, 37, 1344] -> 4 box + 1 class + 32 mask coefficients
# prototypes: [1, 32, 64, 64]
Safetensors
The safetensors file stores the plain PyTorch state_dict (no Ultralytics wrapper). Load it with:
from safetensors.torch import load_file
state_dict = load_file("yolov11-seg-brain.safetensors")
To run inference, rebuild the architecture with Ultralytics and load the weights:
from ultralytics import YOLO
model = YOLO("yolo11m-seg.yaml") # or yolo11m-seg.pt
model.model.load_state_dict(state_dict)
model.model.eval()
Browser demo
A fully client-side demo runs the ONNX model in the browser with ONNX Runtime Web:
https://shahriar-hd.github.io/brain-scan-ai/
Source: https://github.com/shahriar-hd/brain-scan-ai
The demo performs inference locally in the browser. Images are never uploaded to a server. The first run downloads the ~85 MB ONNX model, which the browser caches.
Limitations
- Trained on the Kaggle/TCGA LGG MRI dataset; performance may drop on different scanners, sequences, or DICOM data.
- Single tumor class only; it does not classify tumor type or grade.
- Outputs are 2D slice predictions, not 3D volumetric segmentations.
- Not validated for clinical use.
Citation
If you use this model, please cite the Brain Scan AI project and Ultralytics YOLO11:
@software{brain_scan_ai_yolo11seg,
author = {Shahriar},
title = {Brain Scan AI: YOLO11m-seg Brain Tumor Segmentation},
year = {2025},
url = {https://github.com/shahriar-hd/brain-scan-ai}
}

