How visionml/pytracking works
1. Overall shape
- This is a two-part PyTorch codebase:
- ltr/: offline training framework for learning tracking/video segmentation models.
- pytracking/: runtime trackers, evaluation, analysis, and demo entry points.
- The repo is centered on visual object tracking, with some video object segmentation and multi-object tracking support.
2. Main architectural boundary: training vs inference
- ltr builds and trains model components from datasets and losses.
- pytracking consumes trained checkpoints and runs trackers on videos, benchmarks, webcams, or VOT-style protocols.
- The README’s model zoo links these two halves: models are trained in ltr and then used by tracker implementations in pytracking.
3. Training pipeline in ltr/
- ltr/run_training.py is the top-level training entry point.
- The training flow is: dataset sampling/processing → model/actor forward pass → loss computation → trainer loop.
- ltr/trainers/ contains the generic training loop, while ltr/actors/ wraps a model into a training objective for specific tasks such as tracking, segmentation, or bounding-box regression.
4. Data layer in ltr/
- ltr/dataset/ provides dataset adapters for common tracking and segmentation sources such as LaSOT, GOT-10k, TrackingNet, YouTube-VOS, COCO, DAVIS, LVIS, and synthetic video variants.
- ltr/data/ handles the input pipeline: loaders, samplers, transforms, processing, and bounding-box utilities.
- ltr/data_specs/ contains split files and class maps that define dataset partitions and benchmark-specific training/validation subsets.
5. Model construction in ltr/
- ltr/models/ is organized by reusable primitives and task families:
- Backbones: ResNet, MobileNetV3, Swin Transformer, and variants.
- Layers: normalization, activation, filter, transform, distance, and block utilities.
- Losses: target classification, regression, Lovász, segmentation, KL regression, and candidate matching losses.
- Task-specific model families: DiMP, KYS, LWL, RTS, ToMP, TaMOs, target classifier, target candidate matching, and bounding-box regression.
- ltr/admin/ provides experiment infrastructure such as environment setup, model loading, multi-GPU support, stats, tensorboard, and model construction.
6. Training configurations
- ltr/train_settings/ is where concrete experiment recipes live.
- Each subfolder corresponds to a family such as dimp, kys, lwl, rts, tamos, tomp, bbreg, or keep_track.
- These settings define the exact model, training schedule, and data mix used by the training scripts.
7. Runtime tracking layer in pytracking/
- pytracking/run_tracker.py, run_video.py, run_webcam.py, and run_vot.py are the main execution entry points.
- pytracking/tracker/ contains stateful online tracker implementations, one package per tracker family: ATOM, DiMP, ECO, KeepTrack, KYS, LWL, RTS, TaMOs, and ToMP.
- pytracking/parameter/ mirrors the training settings and supplies tracker-specific runtime hyperparameters and model paths.
8. Feature and math utilities in pytracking/
- pytracking/features/ implements feature extraction, augmentation, preprocessing, and network wrappers around deep backbones.
- pytracking/libs/ contains low-level tracking math: complex-number ops, Fourier tools, optimization, tensor containers, and correlation-filter utilities.
- This layer is what makes classical and hybrid trackers like ECO possible, and also supports newer deep trackers with shared feature code.
9. Evaluation and analysis
- pytracking/evaluation/ defines benchmark datasets, running logic, VOT integration, multi-object wrapping, and dataset environment handling.
- pytracking/analysis/ provides result extraction, plotting, playback, and VOS-specific analysis utilities.
- The repository separates evaluation from tracking execution so the same tracker can be run under different benchmark protocols.
10. External dependencies and special integration points
- The project depends on PyTorch and uses a conda-based installation flow.
- ltr/external/PreciseRoIPooling is a bundled third-party module used by some model components.
- VOT integration is explicitly supported via pytracking/VOT/, and the README mentions benchmark-specific result packaging and dataset attribute specs.
11. How data flows end to end
- Training: benchmark datasets and split files feed samplers and processors; models are trained through actors and trainers; checkpoints are saved for later use.
- Inference: a runtime script loads a tracker parameter set, instantiates the tracker, loads the trained network, and processes frames sequentially while maintaining tracker state.
- Evaluation: the same tracker is run against benchmark dataset wrappers, and outputs are analyzed or packaged into benchmark-specific formats.
12. What to diagram as the key subsystems
- At minimum, show these boundaries:
- Training framework (ltr)
- Runtime/evaluation framework (pytracking)
- Dataset/adaptation layer
- Model family layer
- Tracker runtime layer
- Evaluation/analysis tooling
- The main dependency direction is from datasets/configs into training, then from trained checkpoints into runtime trackers and benchmark evaluation.
Main entry points: tracker Trackers · models Models · train_settings Recipes · evaluation Evaluation
Components 21
LTR training
Offline model training, data, and experiment setup.
- Train entry · Top-level training script.
ltr/run_training.py - Data pipeline · Sampling, transforms, processing, and loader utilities.
ltr/data - Datasets · Adapters for tracking, segmentation, and synthetic video datasets.
ltr/dataset - Split specs · Dataset split files and class maps used by training recipes.
ltr/data_specs - Actors · Wrap models into task-specific training objectives.
ltr/actors - Trainers · Generic training loop and optimization orchestration.
ltr/trainers - Admin · Experiment setup, loading, stats, tensorboard, and multi-GPU support.
ltr/admin - Models · Backbones, layers, losses, and tracking model families.
ltr/models - Recipes · Concrete experiment definitions and schedules per tracker family.
ltr/train_settings
PyTracking runtime
Tracker execution, evaluation, analysis, and runtime parameters.
- Track entry · Main tracker execution script.
pytracking/run_tracker.py - Video entry · Video demo and offline playback runner.
pytracking/run_video.py - Webcam entry · Live webcam tracking runner.
pytracking/run_webcam.py - VOT entry · VOT benchmark execution entry point.
pytracking/run_vot.py - Trackers · Stateful tracker implementations for major model families.
pytracking/tracker - Parameters · Tracker hyperparameters and model-path settings mirrored from training recipes.
pytracking/parameter - Features · Feature extraction, preprocessing, augmentation, and network wrappers.
pytracking/features - Math libs · Fourier, optimization, tensor containers, and DCF utilities.
pytracking/libs - Evaluation · Dataset wrappers, running logic, multi-object support, and VOT integration.
pytracking/evaluation - Analysis · Result extraction, plotting, playback, and VOS analysis.
pytracking/analysis
Cross-cutting
Shared training-to-inference integration points and bundled externals.
- VOT bridge · Bundled VOT tracker integration scripts and config.
pytracking/VOT - External ROI · Bundled PreciseRoIPooling dependency used by model components.
ltr/external/PreciseRoIPooling
Connections 22
- Split specs → Datasets: partitions · Split files and class maps guide dataset adapters.
- Datasets → Data pipeline: samples · Dataset adapters feed the data pipeline.
- Data pipeline → Actors: batches · Processed training batches are consumed by actors.
- Models → Actors: forward/loss · Models are wrapped by task-specific actors.
- Actors → Trainers: objective · Actors provide training objectives to the trainer loop.
- Recipes → Train entry: configure · Experiment recipes drive the training entry point.
- Admin → Train entry: infra · Training uses environment, loading, stats, and multi-GPU support.
- Train entry → Trainers: launch · The main script starts the training loop.
- Models → Recipes: selects · Recipes choose specific model families and variants.
- External ROI → Models: kernel · Bundled third-party ops support some model components.
- Recipes → Parameters: mirrors · Training recipes correspond to runtime parameter sets.
- Models → Trackers: checkpoints · Trained models are loaded by runtime trackers.
- Parameters → Trackers: runtime config · Tracker parameters define runtime behavior and model paths.
- Trackers → Features: extracts · Trackers use feature extraction and preprocessing stacks.
- Trackers → Math libs: math core · Classical and hybrid trackers rely on low-level tracking math.
- Track entry → Trackers: launch · Main tracker entry point instantiates trackers.
- Video entry → Trackers: launch · Video runner executes trackers on frame sequences.
- Webcam entry → Trackers: launch · Webcam runner executes trackers on live input.
- VOT entry → Trackers: launch · VOT entry point runs trackers under benchmark protocol.
- Trackers → Evaluation: benchmark · Trackers are evaluated through benchmark dataset wrappers.
- Evaluation → Analysis: results · Evaluation outputs feed result analysis and plotting.
- Evaluation → VOT bridge: protocol · Evaluation integrates VOT packaging and execution.