Sub topic 15
End-to-End and Transformer-Based Trackers
Assume you know object detection, bounding boxes, basic neural networks, and the tracking-by-detection pipeline. This chapter compares that pipeline with models that learn detection and identity assignment together.
Tracking by Detection Versus Joint Tracking
A tracking-by-detection system has separate stages:
- A detector finds objects in each frame.
- A tracker predicts existing tracks.
- An association algorithm matches detections to tracks.
- Track management creates and removes identities.
SORT, DeepSORT, and ByteTrack follow this pattern. It is modular and easy to debug. You can replace the detector without redesigning the tracker. However, errors pass between stages. A missed detection can cause a track to disappear, and two nearby detections can receive swapped identities.
An end-to-end tracker learns more of this process in one model. It receives a sequence of frames and produces boxes with track identities. Training can teach the model both where objects are and which objects belong to the same trajectory.
| Approach | Main association method | Strength | Common cost |
|---|---|---|---|
| Tracking by detection | IoU, motion, or appearance matching | Modular and efficient | Errors propagate between stages |
| Joint neural tracker | Learned temporal features and queries | Learns detection and identity together | More data, memory, and tuning |
| Transformer tracker | Attention over frame features and track queries | Handles long-range context | Higher latency and compute |
How Transformer Trackers Maintain Identity
A transformer uses attention to compare features. A video frame first passes through a backbone that creates visual features. A transformer encoder processes those features. The decoder then uses object queries.
An object query is a learned vector that represents one possible object. In a video tracker, a query can also carry the identity and history of an existing track. The model updates that query when it sees the next frame.
A simplified flow looks like this:
Models such as TrackFormer and MOTR use this general idea. A query that represents object 7 at time t is passed into time t+1. Attention lets it search the new frame for matching evidence. If the object is briefly hidden, the query can preserve information about its last visible state.
Training and Matching
Training usually uses set prediction. The model produces a set of predictions without ordering them by left-to-right position. A matching step pairs predictions with ground-truth objects. The loss can include:
- Classification loss for the object category.
- Box regression loss for location and size.
- Identity or trajectory loss for temporal consistency.
- “No object” loss for unused queries.
This removes some hand-designed association rules, but it does not remove the need for careful data. Long occlusions, crowded scenes, and camera motion still make identity learning difficult.
Choosing an Architecture
Use tracking by detection when you need a fast, modular system, have limited training data, or already have a reliable detector. Use a transformer-based tracker when temporal context matters, you can train or fine-tune a large model, and latency and memory fit your deployment hardware.
A joint model may simplify inference code, but debugging becomes harder because detection and association errors are entangled. Measure both box quality and identity quality before replacing a working modular tracker.
> callout tip > End-to-end does not mean error-free. It means that more decisions are learned inside one optimization process.
Exercise
A warehouse camera needs real-time tracking on an edge device, and an existing detector already meets the required accuracy. Which approach is the safer starting point, and why?
Show answer
Start with tracking by detection. Its modules are replaceable, its compute is easier to control, and an existing detector avoids training a larger joint model.