# DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection

DINO improves DETR-like detectors with contrastive denoising and mixed query selection

Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu and 2 more · arXiv · 2022-3-7

- **Problem** DETR-like detectors remained under 50 AP on COCO, and nobody had reported how they scale to larger backbones and datasets.
- **Method** DINO adds negative denoising queries that teach the decoder to reject empty anchors, and it picks initial anchor boxes from encoder features.
- **Results** DINO reaches 49.4 AP on COCO with ResNet-50, beating the previous best DETR-like model, DN-DETR.

## Where DETR-like detectors fall short

DETR drops anchor generation and non-maximum suppression by casting detection as a set prediction problem solved with bipartite graph matching. Its training converges slowly, and what its learnable queries represent is unclear, so later work added deformable attention, decoupled positional and content information, and spatial priors.

DAB-DETR treats each query as a dynamic anchor box, and DN-DETR adds a denoising technique to stabilize bipartite matching, so the two together move DETR-like models closer to classical detectors.

The authors identify two open concerns. The best DETR-like models are still under 50 AP on COCO, and no report had shown how these models behave when the backbone and the training data are scaled up. DINO is designed to address both concerns by changing the denoising training, the query initialization and the box prediction of a DETR-like model built on DN-DETR, DAB-DETR and Deformable DETR.

## Starting point and overall pipeline

A DETR query has a positional part and a content part, and DAB-DETR writes the positional part as a 4D anchor box with center coordinates x and y and size w and h. This explicit box form lets the anchor be refined layer by layer in the decoder.

Because a noised ground-truth box behaves like an anchor with a ground-truth box nearby, the auxiliary denoising loss can be added to any DETR-like model.

Deformable DETR contributes two ideas that DINO reuses: query selection, which takes features and reference boxes from the encoder as decoder inputs, and iterative box refinement with gradient detachment between decoder layers, which the authors call look forward once.

In the DINO pipeline, multi-scale features from a backbone such as ResNet-50 or SwinL pass through the Transformer encoder, the top-K encoder features initialize anchor boxes as positional queries, and the content queries stay learnable. The decoder uses deformable attention to combine encoder features and refines the queries layer by layer, with an extra denoising branch that carries the contrastive denoising queries.

## Contrastive denoising queries

DN-DETR learns to predict from anchors that have a ground-truth box nearby, but it does not learn to predict no object for anchors without one. Contrastive denoising adds negative queries so that the decoder learns to reject such anchors.

Two noise scales, \\(\\lambda\_1\\) and \\(\\lambda\_2\\) with \\(\\lambda\_1 \< \\lambda\_2\\), split the noised queries. Positive queries lie inside the inner square of noise and must reconstruct their ground-truth box, while negative queries lie between the inner and outer squares and must predict no object. The authors use a small \\(\\lambda\_2\\) because hard negatives close to a ground-truth box are more useful for learning.

For an image with n ground-truth boxes, one CDN group contains 2 × n queries, one positive and one negative for each box, and several groups are used as in DN-DETR. The reconstruction losses are the L1 and GIoU losses for boxes and the focal loss for classification, and the focal loss also classifies the negative queries as background.

The authors trace two failure modes to anchor confusion, in which several anchors sit near one object. The first is duplicate predictions, and in the left panel of their qualitative figure a boy has 3 duplicate boxes with DN queries, which CDN queries remove. The second is that an anchor far from its ground-truth box may be selected, and CDN is said to teach the model to reject such anchors more strongly than DN does.

## Measuring how far anchors land from their targets

The authors define Average Top-K Distance, ATD(k), over the matched ground-truth boxes \\(b\_i\\) and their initial anchors \\(a\_i\\). For each match they take the L1 distance \\(\\\|b\_i - a\_i\\\|\_1\\), keep the k largest distances and average them.

The authors focus on the largest distances because confusion is more likely when a ground-truth box is matched to a far anchor. They report that DN already picks good anchors overall, while CDN finds better anchors for small objects, as the ATD(100) curves on all objects and on small objects show.

On small objects in the 12-epoch ResNet-50 multi-scale setting, CDN queries improve AP by 1.3 over DN queries.

## Mixed query selection

DETR and DN-DETR use static decoder queries that do not depend on the image, while Deformable DETR's query selection variant takes the top-K encoder features from the last encoder layer and uses them to build both positional and content queries. Efficient DETR also takes top-K encoder features, ranked by an objectness score.

DINO keeps the selection step but applies it only to the anchor boxes, which become the positional queries, while the content queries remain learnable. The authors' reason is that the selected encoder features are not yet refined content features and can mix several objects or cover only part of one, so using them as content queries could mislead the decoder.

## Look forward twice box updates

In look forward once, detaching gradients between layers means that layer i is updated only from the auxiliary loss on its own boxes. Look forward twice instead lets the parameters of layer i receive losses from both layer i and layer i+1, so the box offset predicted in a later layer can also correct the earlier layer.

The final precision of a predicted box depends on two things, the quality of its initial box and the predicted offset. Look forward once improves only the offset, while look forward twice improves the initial box too.

The update for each layer can be written as follows, with \\(b'\_i\\) the undetached box and \\(b\_i\\) its detached copy. \\\[ \\Delta b\_i = \\text{Layer}\_i(b\_{i-1}),\\quad b'\_i = \\text{Update}(b\_{i-1},\\Delta b\_i),\\quad b\_i = \\text{Detach}(b'\_i),\\quad b^{(pred)}\_i = \\text{Update}(b'\_{i-1},\\Delta b\_i) \\\] Update refines a box by an offset in the same way as Deformable DETR, where boxes are normalized to values between 0 and 1 and two boxes are summed after inverse sigmoid and mapped back with sigmoid.

## Results with ResNet-50 at 12 epochs

Table 1 compares DINO against convolution-based and DETR-like detectors on COCO val2017 with ResNet-50, and DINO uses 900 queries while the other DETR-like models use 300 queries, except DETR with 100.

DN-Deformable-DETR with 4 scales reaches 43.4 AP, and DINO reaches 49.0 with 4 scales and 49.4 with 5 scales, which the table lists as +5.6 and +6.0 AP.

Speed and GFLOPS were measured on the same A100 GPU for all models in the table.

## Results at 24 and 36 epochs

Table 2 compares DINO with several detectors at 24 and 36 epochs, against DN-Deformable-DETR trained for 50 epochs at 48.6 AP. The authors chose the 24 and 36 epoch settings instead of the common 50 epoch setting, because DINO converges faster and gains less from 50 epochs.

With 24 epochs, DINO reaches 50.4 AP with 4 scales, +1.8 over that baseline, and 51.3 AP with 5 scales, +2.7. With 36 epochs, DINO reaches 50.9 AP with 4 scales, +2.3, and 51.2 AP with 5 scales, +2.6.

The convergence curves for DINO and two earlier state-of-the-art models are compared in the same setting.

## Scaling to SwinL and Objects365

The large model uses a SwinL backbone pre-trained on ImageNet-22K, is pre-trained on Objects365 and then fine-tuned on COCO train2017, and is evaluated on val2017 and test-dev. Objects365 has 1.7M annotated images.

The authors also compare pre-training data. Florence pre-trains its backbone on 900M image-text pairs and its detector on 9M images, and the authors state that DINO uses 1/60 of the backbone pre-training images and 1/5 of the detection pre-training images.

The ResNet-50 models are trained on train2017 without extra data, while the SwinL variant is pre-trained on Objects365 first.

## Which components account for the gains

Table 4 starts from the original DN-DETR at 43.4 AP, adds optimized DN-DETR at 44.9 AP, then adds pure query selection for a strong baseline at 46.5 AP. Each later row adds one component on top of the row before it, so the rows are cumulative.

Mixed query selection raises AP from 46.5 to 47.0 over the pure query selection baseline.

Removing any of the added components lowers AP in this table, which supports keeping each one, but the ablation does not test each component alone on top of the baseline.

## Limitations

Table 3 places DINO next to published results from other models, which were pre-trained on different data, and the authors list DyHead's detection pre-training data as undisclosed. These entries are not re-run under the same conditions as DINO.

The 63.3 AP test-dev figure uses test time augmentation, and without it the score is 63.2. The authors say that their result without test time augmentation is a plain result without extra tricks.

In Table 4, the small-object AP drops in the look forward twice row while overall AP rises, and the paper's reported ablation uses a cumulative order rather than testing each component alone.

## Paper info

- **Authors**: Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu, Lionel M. Ni, Heung-Yeung Shum
- **Venue**: arXiv · Preprint
- **First published**: 2022-3-7
- **Added**: 2026-11-12
- **Updated**: 2022-7-11
- **Version**: v4
- **arXiv**: 2203.03605
- **Category**: cs.CV
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/2203.03605v4) · [PDF ↗](https://arxiv.org/pdf/2203.03605v4)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Hao Zhang, Feng Li, Shilong Liu, Lei Zhang, Hang Su, Jun Zhu, Lionel M. Ni, Heung-Yeung Shum (2022). DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection. arXiv:2203.03605v4. https://arxiv.org/abs/2203.03605v4

**BibTeX**

```
@misc{zhang2022dino,
  title = {{DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection}},
  author = {Hao Zhang and Feng Li and Shilong Liu and Lei Zhang and Hang Su and Jun Zhu and Lionel M. Ni and Heung-Yeung Shum},
  year = {2022},
  eprint = {2203.03605},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.03605v4}
}
```

## Related papers

- [Deformable DETR: Deformable Transformers for End-to-End Object Detection](https://refivu.com/en/papers/e0311cd6-f252-409d-a37d-7b236622ec8e-deformable-detr-deformable-transformers-for-end-to-end.md)
- [Focal Loss for Dense Object Detection](https://refivu.com/en/papers/e443afaf-8dd8-45c6-8192-0357f4961dd2-focal-loss-for-dense-object-detection.md)
- [Improved Baselines with Momentum Contrastive Learning](https://refivu.com/en/papers/b3c4bdf4-000b-4115-9c61-4869e9e62ccc-improved-baselines-with-momentum-contrastive-learning.md)
- [Revisiting RadioGalaxyNET: modern detectors for radio galaxy detection and host identification](https://refivu.com/en/papers/a605052b-bc2f-40db-bb5f-0a2af05e1533-revisiting-radiogalaxynet-modern-detectors-for-radio-galaxy.md)
- [Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection](https://refivu.com/en/papers/d71e5f0f-1f56-4ab0-b2a4-41156c563837-grounding-dino-marrying-dino-with-grounded-pre-training.md)
- [DETRs Beat YOLOs on Real-time Object Detection](https://refivu.com/en/papers/2872fb04-6c8b-4f48-a976-80e6dd5be309-detrs-beat-yolos-on-real-time-object-detection.md)

## Other paper commentary

- [LSUN: Construction of a Large-scale Image Dataset using Deep Learning with Humans in the Loop](https://refivu.com/en/papers/9f84cef9-f864-4975-816c-e96f0a87497d-lsun-construction-of-a-large-scale-image-dataset.md)
- [Ensemble deep learning: A review](https://refivu.com/en/papers/ea9dfe6e-facd-4eab-ba72-3f4f7be98df5-ensemble-deep-learning-a-review.md)
- [Benchmarking Single Image Dehazing and Beyond](https://refivu.com/en/papers/e56ca83c-da79-4a86-ba3f-0e290a906769-benchmarking-single-image-dehazing-and-beyond.md)
- [Object Detection in Optical Remote Sensing Images: A Survey and A New Benchmark](https://refivu.com/en/papers/9963ea9e-19c4-4bf2-8e66-d7887d703d1e-object-detection-in-optical-remote-sensing-images-a.md)
- [AffectNet: A Database for Facial Expression, Valence, and Arousal Computing in the Wild](https://refivu.com/en/papers/93b39bb6-a5c2-45b8-8cd8-f4785271bb90-affectnet-a-database-for-facial-expression-valence-and.md)
- [Objects as Points](https://refivu.com/en/papers/15289860-cbb9-4b2e-92d1-6e9088d6effa-objects-as-points.md)
- [Time Series Classification from Scratch with Deep Neural Networks: A Strong Baseline](https://refivu.com/en/papers/8883de27-afd8-4d47-acd8-ad01a7dfe332-time-series-classification-from-scratch-with-deep-neural.md)
- [A Diversity-Promoting Objective Function for Neural Conversation Models](https://refivu.com/en/papers/a4f62a40-246e-47fd-bbb9-33f09731586c-a-diversity-promoting-objective-function-for-neural.md)
- [The Arcade Learning Environment: An Evaluation Platform for General Agents](https://refivu.com/en/papers/2c89eed5-9dfb-4243-8466-0655582e3266-the-arcade-learning-environment-an-evaluation-platform-for.md)
- [A Call for Clarity in Reporting BLEU Scores](https://refivu.com/en/papers/626061b1-f2e9-4997-a6e6-2f15df6f8b3f-a-call-for-clarity-in-reporting-bleu-scores.md)

## Terms in this paper

- [Transformer](https://refivu.com/en/terms/48e8be2570bc-transformer)
- [Object detection](https://refivu.com/en/terms/113bfdb14049-object-detection)
- [ResNet-50](https://refivu.com/en/terms/eb2323a60a89-resnet-50)
- [DETR](https://refivu.com/en/terms/86857f2f379d-detr)
- [deformable attention](https://refivu.com/en/terms/863041c104f6-deformable-attention)
- [Objects365](https://refivu.com/en/terms/c0164e60f593-objects365)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/db31b9c4-53eb-4f35-b73e-46eb633cfd32-dino-detr-with-improved-denoising-anchor-boxes-for)
