Sub topic 17
Deformable DETR and Other Fixes for DETR's Weaknesses
Assume that you know convolutional feature maps, attention, gradient descent, and DETR's object-query and Hungarian-matching pipeline. This chapter focuses on why original DETR can be slow or inaccurate and how later models address those problems.
Why Original DETR Struggles
DETR removes anchors and non-maximum suppression by predicting a fixed-size set of objects. This design is simple, but the first version has two important weaknesses:
- Slow convergence: Each object query can attend to every location in the feature map. Early in training, queries must learn where useful objects are before they can specialize.
- Weak small-object detection: Original DETR often uses a single, low-resolution feature map. Small objects may occupy only a few feature cells.
- High attention cost: Global attention compares every query with every spatial location. The cost grows with the number of pixels in the feature map.
These problems are related. High-resolution maps contain useful small-object detail, but global attention over those maps is expensive.
Deformable Attention
Deformable DETR replaces global attention with deformable attention. Instead of examining every feature location, a query predicts a small set of sampling points around a reference point. It gathers features from those points and combines them with learned weights.
The reference point usually represents a likely object center. During training and decoding, the model can refine this point and move the sampling locations toward useful evidence.
Deformable DETR also uses multi-scale feature maps. A feature pyramid supplies high-resolution maps for small objects and low-resolution maps for large objects. Each query samples a few points from several scales rather than processing every position at every scale.
If a feature map has many locations but each query samples only a small fixed number, attention becomes much cheaper. This makes high-resolution information practical.
Other Improvements
Later DETR-family models improve training and matching in different ways.
| Improvement | Main problem addressed | Basic idea |
|---|---|---|
| Conditional DETR | Queries search too broadly | Use content and position to guide attention |
| DN-DETR | Slow learning of object queries | Train with deliberately corrupted known boxes |
| DINO | Unstable or duplicate predictions | Use denoising, better query initialization, and box refinement |
| Deformable DETR | Expensive global attention and small objects | Sparse attention across multiple feature scales |
Iterative box refinement lets each decoder layer update a box and pass the improved box to the next layer. This gives later layers a better spatial starting point.
Denoising training adds noisy versions of ground-truth labels and boxes during training. The model learns to reconstruct the original objects. This provides a clearer learning signal before ordinary queries become reliable.
These changes preserve DETR's set-prediction idea, so inference still does not require NMS. However, they add architectural choices and training procedures. A deformable model is more complex than original DETR, and its sparse sampling pattern may miss evidence if reference points are poor.
Choosing a DETR Variant
Use deformable attention when small objects, high-resolution inputs, or training speed matter. Use a simpler DETR implementation when clarity and experimentation matter more than peak detection quality. When evaluating a variant, compare convergence speed, small-object average precision, memory use, and inference latency rather than relying only on overall mAP.
Exercise
Why does Deformable DETR use sampling points from multiple feature-map scales?
Show answer
High-resolution maps preserve small-object details, while lower-resolution maps represent large objects efficiently. Sampling both scales gives the query useful information without global attention over every location.