Computer Vision Lab Models DETR (ResNet-50)
DETR (ResNet-50)
CNN backbone + transformer encoder–decoder, 100 object queries
Knowledge card: reformulates detection as set prediction: no anchors and no NMS, and Hungarian matching enforces one prediction per object. The price is long training (500 epochs) and relative weakness on small objects.
| Architecture | CNN backbone + transformer encoder–decoder, 100 object queries |
|---|---|
| Task | Object detection |
| Training data | COCO 2017 |
| the number of parameters | ≈41M (paper) |
| Framework | PyTorch |
| File size | 159 MB |
| Licence | Apache-2.0 |
| Where it runs | Knowledge card only |
| Official source | github.com |
| Official weights | dl.fbaipublicfiles.com |
Published metrics (from the official source, not measured by this site)
| Metric | Value | Evaluation data | Source |
|---|---|---|---|
| box AP | 42.0 | COCO val2017 (500 epochs) | Source |
Architecture diagram
- Input / output
- Convolutional layer
- Attention / transformer
- Composite block
- Embedding / tokens / queries
- Output head
- Loss / training only
Detailed model explanation
Idea and intuition
DETR (DEtection TRansformer) reformulated detection as set prediction: the model outputs a fixed number N of predictions (100 in the paper), and they are compared with the ground-truth objects through an optimal «bipartite matching» with the Hungarian algorithm. Since each ground-truth object is matched to only one prediction, the model learns by itself not to duplicate boxes, so there is no need for NMS or anchors.
Architecture
- A CNN backbone (ResNet-50) produces a feature map at 1/32 resolution, whose channels are reduced to
d=256and flattened into a sequence. - A transformer encoder with six self-attention layers, with a 2D sinusoidal positional encoding.
- A transformer decoder with six layers that receives
Nlearned «object queries», each attending to the others and to the encoder features. - A small FFN per query outputs a class (with a «no object» class ∅) and a normalised box.
Mathematical formulation
The optimal matching between ground-truth objects y and predictions \hat y:
\hat\sigma = \arg\min_{\sigma\in\mathfrak S_N}\sum_{i=1}^{N}\mathcal L_{match}\big(y_i,\hat y_{\sigma(i)}\big)\mathcal L_{Hungarian} = \sum_{i=1}^{N}\Big[-\log\hat p_{\hat\sigma(i)}(c_i) + \mathbb 1_{c_i\neq\varnothing}\big(\lambda_{L1}\lVert b_i-\hat b_{\hat\sigma(i)}\rVert_1 + \lambda_{giou}\mathcal L_{giou}(b_i,\hat b_{\hat\sigma(i)})\big)\Big]Performance
According to the official repository, DETR with a ResNet-50 backbone reaches AP = 42.0 on COCO val2017 after a long training schedule (500 epochs).
Strengths and limitations
- Strength: a simple end-to-end pipeline with no anchors and no NMS.
- Strength: global attention helps large objects and relations between objects.
- Limitation: very slow training convergence, which later works such as Deformable DETR and RT-DETR addressed.
- Limitation: weaker on small objects because the features are single-scale and low-resolution.
Uses
Detection, the basis of the DETR family (Deformable DETR, DINO-DETR and RT-DETR) and query-based segmentation.
Runtime requirements
GPU for training.
How to load
Not loaded in the lab (knowledge card).
References
- N. Carion, F. Massa, G. Synnaeve, N. Usunier, A. Kirillov, S. Zagoruyko (2020).End-to-End Object Detection with Transformers. arXiv:2005.12872 (ECCV 2020). doi:10.48550/arXiv.2005.12872
- A. Vaswani et al. (2017).Attention Is All You Need. arXiv:1706.03762 (NeurIPS 2017). doi:10.48550/arXiv.1706.03762
