RT-DETRv2 (ResNet-vd, S / M / M* / L / X) (fastforks)

RT-DETRv2 (Lv et al. 2024, Baidu): real-time end-to-end detection; ResNet-vd backbone, hybrid encoder (one attention layer, CSP-RepVGG feature pyramid), deformable-attention decoder over 300 selected queries, no NMS; boxes, scores and COCO classes at the input size. The portable module() is the whole network at 640x640 (class logits and normalised boxes).

This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: https://github.com/kleinicke/fastforks. Kernels for the kernels backend: https://huggingface.co/fastforks/kernels. Original code: https://github.com/lyuwenyu/RT-DETR at df2a96c8c3a0.

Task: detection. Tier: stable. Outputs: boxes, scores, labels. Backends: portable, kernels.

Input: one RGB image. Output: boxes, class labels, scores and instance masks.

Variants

Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in card.toml.

variant weights (author link) SHA-256 weights licence commercial use
rtdetrv2-l-coco@1 rtdetrv2_r50vd_6x_coco_ema.pth a1f30829515a Apache-2.0 (assumed from code) yes
rtdetrv2-m-coco@1 rtdetrv2_r34vd_120e_coco_ema.pth ff617569a0b7 Apache-2.0 (assumed from code) yes
rtdetrv2-ms-coco@1 rtdetrv2_r50vd_m_7x_coco_ema.pth f2df6de01905 Apache-2.0 (assumed from code) yes
rtdetrv2-s-coco@1 rtdetrv2_r18vd_120e_coco_rerun_48.1.pth 2ace52184b62 Apache-2.0 (assumed from code) yes
rtdetrv2-x-coco@1 rtdetrv2_r101vd_6x_coco_from_paddle.pth 790b95401eca Apache-2.0 (assumed from code) yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: LICENSE.

Code licence: Apache-2.0; the authors do not state a separate weights licence.

Training data: COCO 2017 (train, instance annotations), ImageNet-1k (ILSVRC 2012 classification) (COCO 2017 train (72 to 84 epochs); the ResNet-vd backbones start from ImageNet-1k (PaddleClas) pretraining).

Licence evidence: https://github.com/lyuwenyu/RT-DETR/blob/df2a96c8c3a098567a1149bf0248da6efe6d495d/LICENSE

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): rtdetrv2-l-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); rtdetrv2-m-coco 3000x4000 (0.5 GiB peak allocated, 0.7 reserved); rtdetrv2-ms-coco 3000x4000 (0.5 GiB peak allocated, 0.7 reserved); rtdetrv2-s-coco 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); rtdetrv2-x-coco 3000x4000 (0.6 GiB peak allocated, 0.8 reserved)

Speed and memory

Detection, synthetic, 800x1344

model time (ms): original fp32 original portable kernels kernels speed-up: vs original vs portable peak memory (MiB, allocated / reserved): original portable kernels
rtdetrv2-l-coco 30.3 38.4 12.14 6.61 4.6x 1.8x 354 / 412 177 / 200 200 / 306
rtdetrv2-m-coco 17.1 20.9 10.43 5.27 3.2x 2.0x 254 / 270 156 / 170 177 / 274
rtdetrv2-ms-coco 24.7 22.5 9.6 5.46 4.1x 1.8x 309 / 358 166 / 182 189 / 306
rtdetrv2-s-coco 14.1 16.8 8.04 4.19 3.4x 1.9x 192 / 220 134 / 166 155 / 250
rtdetrv2-x-coco 36.3 46.8 14.61 9.24 3.9x 1.6x 589 / 622 244 / 278 262 / 384

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
rtdetrv2-l-coco 0.66 0.50 0.25โ€  0.04 0.01 0.02
rtdetrv2-m-coco 0.45 0.33 0.16โ€  0.02 0.01 0.01
rtdetrv2-ms-coco 0.52 0.45 0.17โ€  0.06 0.03 0.09
rtdetrv2-s-coco 1.32 0.31 0.46โ€  0.42 0.10 0.53
rtdetrv2-x-coco 1.13 1.09 0.29โ€  0.08 0.05 0.02

Fixed-size speed and peak memory, all models

model mode 640x480 1280x720 1920x1080 12 MP 4000x3000
rtdetrv2-l-coco portable 24.1 ms / 171 / 202 15.4 ms / 176 / 204 13.2 ms / 204 / 226 18.2 ms / 574 / 698
rtdetrv2-l-coco kernels 6.4 ms / 205 / 328 6.5 ms / 213 / 338 7.1 ms / 240 / 338 16.4 ms / 610 / 758
rtdetrv2-m-coco portable 9.4 ms / 147 / 178 11.9 ms / 155 / 202 12.8 ms / 181 / 216 16.1 ms / 552 / 688
rtdetrv2-m-coco kernels 5.1 ms / 182 / 312 5.3 ms / 189 / 324 5.8 ms / 216 / 336 15.1 ms / 586 / 752
rtdetrv2-ms-coco portable 9.9 ms / 160 / 190 9.5 ms / 166 / 200 9.7 ms / 193 / 228 16.6 ms / 563 / 700
rtdetrv2-ms-coco kernels 5.3 ms / 195 / 314 5.4 ms / 202 / 326 6.0 ms / 229 / 338 15.2 ms / 600 / 760
rtdetrv2-s-coco portable 7.7 ms / 128 / 154 17.8 ms / 135 / 164 10.2 ms / 160 / 192 14.8 ms / 530 / 664
rtdetrv2-s-coco kernels 4.0 ms / 161 / 288 4.1 ms / 168 / 300 4.7 ms / 194 / 312 14.0 ms / 564 / 728
rtdetrv2-x-coco portable 15.4 ms / 237 / 264 23.5 ms / 244 / 274 18.4 ms / 266 / 302 22.8 ms / 636 / 774
rtdetrv2-x-coco kernels 9.0 ms / 272 / 390 9.2 ms / 279 / 402 9.8 ms / 302 / 414 19.0 ms / 673 / 836

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (RTX 5060 Ti 16 GB, sm_120). Original = the authors' code at the precision of portable (fp16, or (fp32) where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.

Accuracy

Parity with the original code

Every variant is checked against golden outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 px and p99 <= 1.0 px.

Usage

from fastforks import detection

model = detection.load("rtdetrv2-l-coco")  # portable PyTorch on the GPU if there is one, else the CPU
result = model("photo.jpg")
result.boxes, result.scores, result.labels  # [N, 4], [N], [N]
result.backend  # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')

Install with pip install fastforks (see https://github.com/kleinicke/fastforks). Other variants: rtdetrv2-l-coco, rtdetrv2-m-coco, rtdetrv2-ms-coco, rtdetrv2-s-coco, rtdetrv2-x-coco.

Kernels backend

detection.load("rtdetrv2-l-coco", mode="kernels") runs our CUDA kernels (cudnn_hacc). It needs a prebuilt kernel for your GPU architecture (downloaded from https://huggingface.co/fastforks/kernels on first use) and a recent NVIDIA driver; if there is none it raises BackendUnavailableError with the reason and never falls back silently. mode="auto" picks kernels when it can run and logs the choice.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support