Computer Vision Lab Models RT-DETR (R50)

RT-DETR (R50)

Real-time DETR: efficient hybrid encoder + IoU-aware query selection

Knowledge card: the first detector of the DETR family to run in real time and, according to the paper, to outperform contemporary YOLO detectors in both accuracy and speed, without NMS; its speed can be adjusted by changing the number of decoder layers without retraining.

Object detectionKnowledge card

ArchitectureReal-time DETR: efficient hybrid encoder + IoU-aware query selection
TaskObject detection
Training dataCOCO 2017
the number of parameters42M (official repository)
FrameworkPyTorch / PaddlePaddle
File size—
LicenceApache-2.0
Where it runsKnowledge card only
Official sourcegithub.com

Published metrics (from the official source, not measured by this site)

MetricValueEvaluation dataSource
AP53.1COCO val2017, 640×640Source
FPS108T4 GPU, TensorRT FP16Source

Architecture diagram

Architecture diagram RT-DETR (R50)Efficient hybrid encoderInput640×640Backbone (ResNet-50 / HGNetv2)S3stride 8S4stride 16S5stride 32AIFIsingle-scale self-attentionCCFMCNN cross-scale fusionIoU-aware query selectiontop-300 encoder featuresTransformer decoder ×6deformable attention + aux headsBoxes + scoresno NMS
RT-DETR by Zhao et al. (CVPR 2024): an efficient hybrid encoder (AIFI: intra-scale attention on S5 only, and CCFM: cross-scale fusion by convolution), IoU-aware query selection, and a transformer decoder that predicts directly; end-to-end real-time detection without NMS.
  • Input / output
  • Convolutional layer
  • Attention / transformer
  • Composite block
  • Embedding / tokens / queries
  • Memory / intermediate features

Detailed model explanation

Idea and intuition

RT-DETR (Real-Time DETR) is an attempt to make transformer detectors compete with the YOLO family in speed while keeping the advantage of eliminating NMS. The problem with the original DETR is that self-attention over multi-scale features is very costly. So the authors proposed an «efficient hybrid encoder» that separates interaction within a single scale from fusion across scales.

Components

  • Backbone (ResNet or HGNetv2) outputs three maps S3–S5.
  • AIFI (Attention-based Intra-scale Feature Interaction): self-attention on the deepest map S5 only, because it is the richest semantically and the smallest, which greatly reduces the cost.
  • CCFF (CNN-based Cross-scale Feature Fusion): convolutional fusion across scales in the PAN manner.
  • Uncertainty-aware query selection (uncertainty-minimal query selection): the best K encoder features are selected to initialise the decoder queries.
  • Decoder with deformable attention; the number of its layers can be reduced at inference to trade accuracy for speed without retraining.

Mathematical formulation

RT-DETR inherits bipartite matching from DETR, so it does not need NMS. The AIFI idea is essentially standard attention over the sequence of S5 cells:

\mathrm{Attn}(Q,K,V)=\mathrm{softmax}\!\Big(\frac{QK^\top}{\sqrt{d}}\Big)V,\qquad Q=K=V=\mathrm{flatten}(S_5)+\mathrm{PE}

Performance

According to the official repository: RT-DETR-R50 reaches 53.1 AP on COCO val2017, with about 42 million parameters and 108 frames per second on a T4 with TensorRT FP16.

Strengths and limitations

  • Strength: real-time speed without NMS, so inference time is more stable and unaffected by the number of boxes.
  • Strength: flexible speed tuning by changing the number of decoder layers.
  • Limitation: training is more complex and more sensitive to hyperparameters than convolutional detectors.
  • Limitation: the published figures are measured on specific hardware (T4 + TensorRT) and may differ on your hardware.

Uses

Real-time detection on GPU, powerful embedded systems.

Runtime requirements

GPU with TensorRT for the published speed.

How to load

Not loaded in the lab (knowledge card).

References

  1. Y. Zhao et al. (2023).DETRs Beat YOLOs on Real-time Object Detection. arXiv:2304.08069 (CVPR 2024). doi:10.48550/arXiv.2304.08069
  2. 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

Related algorithms