RT-DETR

Zhao (Baidu) 2023 · Paper

One-line summary — First real-time end-to-end Transformer detector, matching YOLO speed while keeping DETR’s clean NMS-free set prediction (“DETRs Beat YOLOs on Real-time Object Detection”).

Problem

The YOLO series dominates real-time detection through a reasonable speed/accuracy trade-off, but both its speed and its accuracy are negatively affected by NMS post-processing: two thresholds (confidence and IoU) must be tuned per scenario, and NMS execution time varies with the number of boxes. The paper quantifies this — with YOLOv8, moving the confidence threshold from 0.001 to 0.05 drops AP from 52.9% to 51.2% while NMS time falls from 2.36 ms to 1.06 ms; anchor-based YOLOs produce ~3x more boxes and thus need more NMS time than anchor-free ones. End-to-end Transformer detectors (DETRs) eliminate NMS via bipartite matching, but their computational cost — especially the multi-scale Transformer encoder, which accounts for 49% of Deformable-DETR’s GFLOPs while contributing only 11% of its AP — kept them out of the real-time regime.

Method & architecture

RT-DETR = backbone + efficient hybrid encoder + Transformer decoder with auxiliary prediction heads. The last three backbone stages {S3,S4,S5}\{\mathcal{S}_3, \mathcal{S}_4, \mathcal{S}_5\} feed the encoder; the decoder iteratively refines a fixed set of object queries into (category, box) pairs — no anchors, no NMS.

Efficient hybrid encoder decouples the two jobs the vanilla multi-scale encoder does at once:

Q=K=V=Flatten(S5),F5=Reshape(AIFI(Q,K,V)),O=CCFF({S3,S4,F5})\mathcal{Q}=\mathcal{K}=\mathcal{V}=\texttt{Flatten}(\mathcal{S}_5),\quad \mathcal{F}_5=\texttt{Reshape}(\texttt{AIFI}(\mathcal{Q},\mathcal{K},\mathcal{V})),\quad \mathcal{O}=\texttt{CCFF}(\{\mathcal{S}_3,\mathcal{S}_4,\mathcal{F}_5\})

Uncertainty-minimal query selection: prior query-selection schemes pick top-KK (K=300K=300) encoder features by classification score alone, so features with poor localization become initial queries. RT-DETR defines the uncertainty of encoder feature X^\hat{\mathcal{X}} as the discrepancy between its predicted localization distribution P\mathcal{P} and classification distribution C\mathcal{C}, and optimizes it in the loss:

U(X^)=P(X^)C(X^),X^RD\mathcal{U}(\hat{\mathcal{X}})=\|\mathcal{P}(\hat{\mathcal{X}})-\mathcal{C}(\hat{\mathcal{X}})\|,\quad \hat{\mathcal{X}}\in\mathbb{R}^{D}

L(X^,Y^,Y)=Lbox(b^,b)+Lcls(U(X^),c^,c)\mathcal{L}(\hat{\mathcal{X}},\hat{\mathcal{Y}},\mathcal{Y})=\mathcal{L}_{box}(\hat{\mathbf{b}},\mathbf{b})+\mathcal{L}_{cls}(\mathcal{U}(\hat{\mathcal{X}}),\hat{\mathbf{c}},\mathbf{c})

where c^,b^\hat{\mathbf{c}},\hat{\mathbf{b}} are predicted category and box, c,b\mathbf{c},\mathbf{b} ground truth. This roughly doubles the fraction of selected features that are high-quality in both classification and IoU (0.67% vs 0.30% of features with both scores > 0.5).

Flexible speed tuning: because decoder layers are homogeneous, dropping trailing decoder layers at inference trades accuracy for speed without retraining — e.g., using layer 5 of a 6-layer RT-DETR-R50 loses 0.1% AP (53.1 → 53.0) while cutting 0.5 ms. Width/depth of encoder and decoder scale with the backbone (R18/R34/CSPResNet down to S/M-class models).

Results

COCO val2017, speed on T4 GPU with TensorRT FP16, end-to-end (NMS time included for YOLOs via the paper’s proposed end-to-end speed benchmark):

Why it matters for SLAM

Semantic SLAM front-ends need object detection at frame rate; historically that meant YOLO plus NMS heuristics. RT-DETR delivers Transformer-quality detection in the same compute envelope, and its NMS-free deterministic output is simpler to integrate into SLAM pipelines (stable instance counts for data association, no threshold tuning, predictable latency). It is a natural detector choice for real-time semantic mapping and dynamic-object filtering.