Skip to content

Train ReID

Use train to fit a ReID backbone on a supported person or vehicle re-identification dataset.

Examples

Example

Train on Market1501:

boxmot train \
  --model osnet_x0_25 \
  --dataset market1501 \
  --data-dir /data/reid \
  --device 0

Joint training on multiple datasets:

boxmot train \
  --model lmbn_n \
  --dataset market1501,duke,cuhk03 \
  --data-dir /data/reid \
  --loss triplet \
  --preprocess crop_letterbox \
  --epochs 120 \
  --project runs/reid_train \
  --name lmbn_joint

Core idea

train builds a ReID backbone, loads one or more registered ReID datasets, and optimizes the model with either softmax or triplet-style training.

The crop preprocessing you choose here should match the preprocessing used later at inference time.

Supported datasets

The built-in dataset registry currently includes common ReID benchmarks such as:

  • market1501
  • duke / dukemtmcreid
  • cuhk03
  • msmt17
  • msmt17_merged

You pass the dataset root through --data-dir, and BoxMOT resolves the expected subdirectory layout for the selected dataset.

Main outputs

Training writes an experiment directory under --project/--name, typically containing:

  • best and last checkpoints
  • training logs and metrics
  • periodic validation results

When training finishes, BoxMOT reports the best checkpoint path along with the best validation mAP and rank-1 score.

Resuming and evaluation during training

  • Use --resume with a checkpoint directory or last.pt file to continue an interrupted run.
  • Use --eval-interval to control how often validation runs during training.
  • Use --eval-datasets for extra cross-domain checks during training.

Scope

train is currently a CLI workflow. The documented high-level Boxmot Python facade does not expose a matching train(...) method.

CLI Arguments

boxmot train

Train a ReID model

Usage:

boxmot train [OPTIONS]

Options:

Name Type Description Default
--model choice (resnet50 | resnet101 | mlfn | hacnn | mobilenetv2_x1_0 | mobilenetv2_x1_4 | osnet_x1_0 | osnet_x0_75 | osnet_x0_5 | osnet_x0_25 | osnet_ibn_x1_0 | osnet_ain_x1_0 | lmbn_ain_n | lmbn_n | clip | vit_nano | vit_nano_ain | vit_nano_ain_os | vit_tiny | vit_tiny_parts | vit_tiny_parts3) ReID backbone architecture osnet_x0_25
--dataset text Training dataset (comma-separated for joint training, e.g. market1501,duke,cuhk03,msmt17). Available: cuhk03, duke, dukemtmcreid, market1501, msmt17, msmt17_merged, veri, veri776 market1501
--data-dir path Root directory of the dataset Sentinel.UNSET
--loss choice (softmax | triplet) Training loss type triplet
--preprocess choice (resize | resize_pad) Crop preprocessing method; must match inference-time preprocessing resize
--imgsz text Image size as H,W (e.g. 256,128) 256,128
--batch-size integer Training batch size 64
--lr float Base learning rate 0.00035
--weight-decay float Weight decay 0.0005
--epochs integer Number of training epochs 120
--warmup-epochs integer Linear warmup epochs 10
--eval-interval integer Validate every N epochs 10
--p-ids integer Number of identities per PK batch 16
--k-instances integer Number of instances per identity 4
--margin float Triplet loss margin 0.3
--label-smooth float Label smoothing epsilon 0.1
--center-loss-weight float Center loss weight 0.0005
--pretrained / --no-pretrained boolean Use ImageNet-pretrained backbone True
--device text cuda device, e.g. 0 or cpu or mps cpu
--project path Save directory runs/reid_train
--name text Experiment name exp
--num-workers integer Dataloader workers 4
--seed integer Random seed 42
--eval-datasets text Comma-separated list of extra datasets for cross-domain evaluation (e.g. duke,cuhk03,msmt17) ``
--ema-decay float EMA momentum decay for model averaging (e.g. 0.999). Disabled by default. Inspired by DynaMix None
--gaussian-blur / --no-gaussian-blur boolean Apply random Gaussian blur augmentation False
--color-jitter / --no-color-jitter boolean Apply color jitter augmentation (auto-enabled for ViTs) False
--random-grayscale float Probability of random grayscale conversion (0 to disable) 0.0
--resume path Resume training from a checkpoint dir or last.pt file None
--help boolean Show this message and exit. False