sysnotes
← all notes Computer Vision

Training MaskDINO for instance segmentation

Posted 10 Jun 2026 · cv, maskdino, detectron2, training

MaskDINO gives you detection and instance masks from one transformer head, and on our defect data it beat a Mask R-CNN baseline by a solid margin once the dataset was clean. Notes from getting it to train without fighting it.

Data in COCO, registered once

from detectron2.data.datasets import register_coco_instances
register_coco_instances("defects_train", {},
    "ann/train.json", "images/train")
register_coco_instances("defects_val", {},
    "ann/val.json", "images/val")

Config that mattered

python train_net.py --num-gpus 1 \
  --config-file configs/maskdino_swinl.yaml \
  SOLVER.IMS_PER_BATCH 4 SOLVER.BASE_LR 1e-4 \
  SOLVER.MAX_ITER 40000 MODEL.WEIGHTS maskdino_swinl_coco.pth

What actually moved the metric

Not the model, the labels. Fixing mask boundary sloppiness and de-duplicating near-identical frames pulled up mask AP more than any hyperparameter sweep. Heavy geometric augmentation hurt here because the defects have a consistent orientation on the source footage, so mild crops and photometric jitter only. Watch mask AP and boundary AP separately; box AP can look fine while the masks are mush.