RT-DETR

RT-DETR (Real-Time DEtection TRansformer) is the first real-time end-to-end object detector in the DETR line.

  • Paper: Zhao, Lv, Xu, Wei, Wang, Dang, Liu and Chen (Baidu Inc. / Peking University Shenzhen), DETRs Beat YOLOs on Real-time Object Detection, CVPR 2024, arXiv:2304.08069.
  • Core claim: the YOLO family’s speed advantage is partly an accounting artefact, because YOLO latencies are reported without the NMS post-processing they require; once NMS is priced in, a properly redesigned DETR wins on both axes.
  • Efficient hybrid encoder: decouples intra-scale attention from cross-scale fusion instead of running dense attention over the concatenated multi-scale sequence.
  • Uncertainty-minimal query selection: picks encoder features whose classification and localization predictions agree.
  • Headline result: RT-DETR-R50 reaches 53.1 AP at 108 FPS and RT-DETR-R101 54.3 AP at 74 FPS on COCO val2017 (T4, TensorRT FP16), beating both the / YOLO models and DINO-Deformable-DETR-R50 (50.9 AP at 5 FPS).

Motivation: what NMS actually costs

The paper’s first contribution is measurement rather than architecture. NMS has two thresholds — a confidence threshold that pre-filters boxes and an IoU threshold that governs suppression — and its runtime is dominated by how many boxes survive the first filter.

Number of surviving boxes at different confidence thresholds

Counting the boxes remaining after confidence filtering on the same input shows the anchor-based YOLOv5 producing roughly more candidates than the anchor-free YOLOv8 at every threshold (≈9.3k vs ≈3.6k at ), which is why the paper concludes that anchor-free detectors outperform anchor-based ones at equivalent accuracy simply because they feed NMS less work.

The accuracy/latency trade-off that follows is sharp (Table 1, YOLOv8 on COCO val2017, T4 + TensorRT FP16, timing only the TensorRT EfficientNMS kernel):

IoU thr. (conf )APNMS (ms)Conf. thr. (IoU )APNMS (ms)
0.552.12.240.00152.92.36
0.652.62.290.0152.41.73
0.852.82.460.0551.21.06

Execution time rises as the confidence threshold falls or the IoU threshold rises: a low confidence threshold leaves more boxes to screen, a high IoU threshold discards fewer per round. Buying the last AP (51.2 → 52.9) more than doubles NMS time (1.06 → 2.36 ms), and the best-AP setting is also the slowest. Worse, the right setting is scenario-dependent — recall-oriented deployments want a low confidence and high IoU threshold, precision-oriented ones the reverse — so the thresholds are a deployment-time tuning burden that destabilizes both speed and accuracy. This motivates an end-to-end speed benchmark: measure a detector’s average inference time over COCO val2017 including the NMS plugin, excluding only I/O and MemoryCopy. Under that benchmark, YOLO latencies grow by 1–2.4 ms while a DETR’s do not move at all.

The complementary problem is that DETRs are not real-time. Deformable DETR made multi-scale features affordable, but the concatenated multi-scale sequence is long, and the encoder ends up consuming 49% of the GFLOPs while contributing only 11% of the AP. RT-DETR attacks exactly that block.

Architecture

RT-DETR overview: backbone, efficient hybrid encoder (AIFI + CCFF), uncertainty-minimal query selection, decoder

RT-DETR is a backbone (ResNet-18/34/50/101 or a scaled CSPResNet), an efficient hybrid encoder, uncertainty-minimal query selection, and a standard DETR decoder with auxiliary prediction heads. The last three backbone stages (strides 8/16/32) feed the encoder.

Efficient hybrid encoder

The design is justified by an explicit ladder of encoder variants, each a step away from the DINO-Deformable-R50 encoder:

Encoder variants A through E

  • A — no encoder at all, features simply concatenated.
  • B — a single-scale Transformer encoder (SSE) applied per level, then concatenated: intra-scale interaction only.
  • C — concatenate first, then a multi-scale Transformer encoder (MSE): intra- and cross-scale interaction simultaneously, on one long sequence. This is the conventional DETR encoder.
  • D — decouple them: SSE for intra-scale, a PANet-style convolutional structure (CSF) for cross-scale fusion.
  • E — the proposed hybrid encoder: AIFI for intra-scale, CCFF for cross-scale.

The two modules:

AIFI (Attention-based Intra-scale Feature Interaction) applies a single-scale Transformer encoder layer to only. The argument is semantic: self-attention on high-level features relates conceptual entities that low-level features do not yet contain, so intra-scale attention on / is not merely wasteful but confusing — it risks duplicating and tangling with the high-level interactions. Restricting it to (variant in the ablation) cuts latency by 35% and gains 0.4 AP, so the claim is empirically load-bearing rather than a pure efficiency compromise. It also removes the encoder’s dependence on the total sequence length : attention now runs on the shortest map only.

CCFF (CNN-based Cross-scale Feature Fusion) is a PANet-style fusion path into which fusion blocks are inserted. A fusion block takes two adjacent-scale features, concatenates them, splits into two -convolution paths to adjust channels, passes one through RepBlocks built from RepConv, and merges the two paths by element-wise add. Being convolutional, it is cheap where the feature maps are large.

The encoder is then, exactly:

where restores the flattened sequence to the spatial shape of .

Uncertainty-minimal query selection

Two-stage query selection (Deformable DETR, DINO) picks the top- encoder features by classification score to initialize object queries. RT-DETR’s objection: the detector must model both category and location, so the quality of a feature is a latent variable jointly correlated with classification and localization — ranking by classification alone selects features that are confidently classified but poorly localized, injecting epistemic uncertainty into the decoder’s initialization.

Define the uncertainty of an encoder feature as the discrepancy between its predicted localization distribution and classification distribution :

and fold it into the loss so that it is optimized, not merely measured:

with the predicted category and box and the ground truth. Because the uncertainty term enters the classification loss, a feature whose box and class disagree is penalized in its score, so the top- ranking by score becomes a ranking by joint quality — this is the same IoU-aware alignment idea as the Task-Aligned-Assignment metric and the IoU-aware query selection of DINO, applied to query initialization rather than label assignment. Selection remains top- () by classification score; the boxes of the selected features become the initial position queries.

Classification vs. IoU score of the selected encoder features

The scatterplot of the selected features (only those with classification score ) is the evidence: uncertainty-minimal selection (purple) concentrates toward the top-right — high classification and high IoU — while vanilla selection (green) sits at the bottom-right. Quantitatively there are 138% more purple than green dots with classification score and 120% more with both scores .

Flexible speed tuning

Because the DETR decoder is a stack of homogeneous layers each with its own auxiliary prediction head, any prefix of the stack is a complete detector. RT-DETR exploits this for deployment: train once with decoder layers, then choose how many to run at inference with no retraining and no fine-tuning, trading accuracy for latency along a continuum. The AP difference between adjacent layers shrinks with depth, so the top layers are nearly free to drop (Table 5, RT-DETR-R50, schedule):

Decoder layers usedAPLatency (ms)
653.19.3
553.08.8
452.78.3
352.47.9
251.37.5
149.17.0

Dropping the last layer costs AP and saves ms. This is what a NMS-based detector cannot offer: its only latency knob is the NMS thresholds, which move accuracy and require re-validation. The scaled models exploit the same mechanism — RT-DETR-R50-Dec denotes decoder layers at inference.

Scaling

RT-DETR scales in two directions. Width via the embedding dimension and CCFF channel count, depth via the number of Transformer layers and RepBlocks; additionally the backbone is swapped (R18/R34/R50/R101 or CSPResNet) and the number of decoder layers is varied. The scaled variants halve the RepBlock channels and leave everything else unchanged.

Hyperparameters

Reported training configuration (Appendix Table A; RT-DETR-R50):

SettingValue
DatasetCOCO train2017 / val2017 (+ Objects365 for pre-training)
BackboneImageNet-pretrained ResNet-50 (also R18/R34/R101)
Input size (other DETRs use )
OptimizerAdamW
Base LR
Backbone LR
Frozen BNTrue
Warm-upLinear, start factor , 2000 steps
Weight decay
Gradient clippingNorm
EMA decay
AIFI layers1
RepBlocks per fusion block3
Embedding dim256
Feedforward dim1024
Attention heads8
Feature scales3 ()
Decoder layers6
Object queries300
Decoder sampling points4
Matching cost weightsclass (, ), bbox , GIoU
Loss weightsclass (, ), bbox , GIoU
Denoising200 denoising queries, label noise ratio , box noise scale
Schedule = 12 epochs; final results use = 72 epochs
Augmentationrandom color distort, expand, crop, flip, resize
Hardware4× NVIDIA Tesla V100, batch size 16

The decoder’s training recipe (denoising queries, box noise, auxiliary losses) follows DINO almost exactly — the denoising groups trace back to DN-DETR and the box-as-query formulation to DAB-DETR. RT-DETR’s novelty is confined to the encoder and the query-selection objective.

Results

COCO val2017, /-scale comparison; FPS at batch size 1 on a T4 GPU with TensorRT FP16, YOLO numbers measured under the end-to-end benchmark (Table 2):

ModelBackboneEpochsParams (M)GFLOPsFPSAPAPAPAP
YOLOv5-L–300461095449.067.3––
PPYOLOE-L–300521109451.468.931.466.1
YOLOv6-L (v3.0)–300591509952.870.334.470.1
YOLOv7-L–300361045551.269.735.266.7
YOLOv8-L––431657152.969.835.369.8
YOLOv8-X––682575053.971.035.770.7
Deformable-DETRR505040173–46.265.228.861.7
DN-Deformable-DETRR505048195–48.667.431.063.7
DINO-Deformable-DETRR503647279550.969.034.664.6
RT-DETRR50724213610853.171.334.870.0
RT-DETRR10172762597454.372.736.072.1

Against YOLOs, RT-DETR-R50 improves on YOLOv5-L / PP-YOLOE-L / YOLOv6-L by 4.1 / 1.7 / 0.3 AP while raising FPS by 100.0% / 14.9% / 9.1% and cutting parameters by 8.7% / 19.2% / 28.8%; against YOLOv7-L / YOLOv8-L it gains 1.9 / 0.2 AP at 96.4% / 52.1% more FPS. Against DETRs, RT-DETR-R50 beats DINO-Deformable-DETR-R50 by 2.2 AP and roughly the FPS (108 vs 5) — the FLOPs drop from 279G to 136G, half of which is the encoder redesign, the rest the input.

Hybrid encoder ablation (Table 3, RT-DETR-R50, schedule) — each row is one rung of the A→E ladder:

VariantAPParams (M)Latency (ms)
A (no encoder)43.0317.2
B (+ intra-scale SSE)44.93211.1
C (+ cross-scale, MSE)45.63213.3
D (decoupled: SSE + CSF)46.43512.2
D (intra-scale on only)46.8357.9
E (AIFI + CCFF)47.9429.3

Reading the ladder: intra-scale interaction is worth AP but latency; cross-scale fusion is worth another AP at latency; decoupling the two buys AP while reducing latency 8%, so it is not merely a cost saving; restricting intra-scale attention to cuts latency 35% and still gains AP, confirming that low-level intra-scale attention is actively unhelpful; and the AIFI/CCFF refinement adds AP, with parameters up 20% but latency down 24%.

Query selection ablation (Table 4, RT-DETR-R50, ). and are the proportions of selected features with classification score , and with both classification and IoU :

Query selectionAP
Vanilla47.90.350.30
Uncertainty-minimal48.70.820.67

Scaled models vs. / YOLOs (Appendix Table B): RT-DETR-R50-Dec (154 FPS, 50.3 AP) through Dec (125 FPS, 52.2 AP) outperform every YOLO; RT-DETR-R18-Dec hits 46.5 AP at 217 FPS, beating all models. Against YOLOv6-M, RT-DETR-R50-Dec gains AP and 36% FPS; against YOLOv6-S, RT-DETR-R18-Dec gains AP and 18% FPS.

Objects365 pre-training (Appendix Table C): 12 epochs on Objects365 then fine-tuning on COCO (60 epochs for R18, 24 for R50/R101) gives / / AP for R18/R50/R101 — improvements of / / AP.

Limitations

  • Small objects remain the weak point, the same limitation as every other DETR at comparable model size: RT-DETR-R50’s AP is below YOLOv8-L’s and RT-DETR-R101’s is below YOLOv7-X’s, even though both beat those models on overall AP. Attention on alone plus a purely convolutional path for / is a plausible cause the paper does not isolate.
  • The speed claims depend on the paper’s own end-to-end benchmark; against the conventional (NMS-excluded) numbers that YOLO papers report, the margin narrows considerably. YOLOv10, which removes NMS from the YOLO side entirely, subsequently reversed several of these comparisons.
  • The input is part of the speed story and is not disentangled from the encoder redesign in the headline FLOPs comparison against DINO-Deformable-DETR ().
  • The uncertainty is an discrepancy between two heads’ outputs with no calibration guarantee — it is an alignment regularizer that behaves like epistemic uncertainty, not a principled estimate of it.
  • Training still takes 72 epochs on 4 V100s; RT-DETR is real-time at inference only.

See also

  • DETR — the set-prediction formulation RT-DETR keeps, including the NMS-free bipartite matching that makes the speed argument possible
  • Deformable DETR — supplies the multi-scale deformable decoder; its encoder is exactly the computational bottleneck RT-DETR removes
  • DINO — RT-DETR’s decoder recipe and the IoU-aware query selection that uncertainty-minimal selection refines
  • DN-DETR — the denoising training used in RT-DETR’s decoder (200 denoising queries)
  • DAB-DETR — box-as-query formulation underlying the position queries
  • Conditional DETR — an earlier attack on DETR’s query optimization difficulty
  • YOLOv8 — the detector used throughout the NMS analysis, and a baseline in Table 2
  • LW-DETR — the concurrent real-time DETR that drops the CNN backbone for a plain ViT; it re-measures RT-DETR in its own environment and beats R50 by 0.8 mAP at lower latency
  • YOLOv10 — the reply from the YOLO side: NMS-free training via consistent dual assignments
  • Task-Aligned-Assignment — the same classification/localization alignment idea, applied to label assignment instead of query selection
  • Implementing Research Papers