DETR (ResNet-50 / ResNet-101)
DETR (ResNet-50 and ResNet-101, COCO) from Facebook Research: end-to-end boxes and classes from 100 object queries, no NMS.
stable Fork of facebookresearch/detr@29901c5 · backends: portable, kernels
- Paper End-to-End Object Detection with Transformers ECCV 2020 · first released 26 May 2020
Paper 2020 Added in 0.1.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import detection
model = detection.load("detr-r50-coco") # kernels on a supported GPU, else portable PyTorch
result = model(image)
result.boxes # also: scores, labels
result.backend # what ran: mode, device, dtype, kernels fastforks bench detr-r50-coco Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Kernels runs fp16. Portable runs fp16 on CUDA.
Input: synthetic, 800x1344 (the task’s standard size)
| Backend | dtype | Time per call (ms) | vs original fp32 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32incl. CPU resize + host copy (official pipeline) | fp32 | 55.5 | – | 491 MiB/540 MiB | 0.6 | 0.12 |
| Original fp16torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline) | fp16 | 62.0 | 0.90× | 459 MiB/558 MiB | 2.5 | 0.83 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 12.4 | 4.5× | 280 MiB/332 MiB | 0.7 | 0.44 |
| Kernels | fp16 | 9.93 | 5.6× | 218 MiB/272 MiB | 0.3 | 0.03 |
| Portable + torch.compile | 9.27 | 6.0× | 233 MiB/292 MiB | 22 (build) | – | |
| TensorRT fp16 | fp16 | 4.40 | 13× | 182 MiBenginenot comparable | 33 (build) | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-02 to 2026-11-04. Median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
| Device | Backend | dtype | ms / call | Peak memory | Output vs reference | Input |
|---|---|---|---|---|---|---|
| Apple M1 Pro 16 GB MPS, torch 2.14.1, 2026-11-14 | Original | fp32 | 237 | 1,954 MiB process | – | 800x1344 |
| Portable | fp16 | 105 | 1,954 MiB process | matches | 800x1344 | |
| Portable | fp32 | 125 | 1,995 MiB process | matches | 800x1344 | |
| Kernels | fp16 | not implemented | – | 800x1344 | ||
| NVIDIA L4 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 13.7 | 256 MiB/312 MiB | – | 800x1344 |
| Kernels | fp16 | 11.8 | 194 MiB/232 MiB | – | 800x1344 | |
| NVIDIA L40S CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 10.1 | 256 MiB/312 MiB | – | 800x1344 |
| Kernels | fp16 | 8.21 | 195 MiB/232 MiB | – | 800x1344 | |
| NVIDIA A10 CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 13.1 | 256 MiB/312 MiB | – | 800x1344 |
| Kernels | fp16 | 8.64 | 193 MiB/232 MiB | – | 800x1344 | |
| NVIDIA A100-SXM4-40GB CUDA, torch 2.14.1+cu130, 2026-11-07 | Portable | fp16 | 10.7 | 256 MiB/312 MiB | – | 800x1344 |
| Kernels | fp16 | 8.82 | 193 MiB/232 MiB | – | 800x1344 | |
| NVIDIA RTX PRO 6000 CUDA, torch 2.14.1+cu130, 2026-11-08 | Portable | fp16 | 3.32 | 280 MiB/332 MiB | – | 800x1344 |
| Kernels | fp16 | 3.14 | 221 MiB/252 MiB | – | 800x1344 | |
CUDA memory is torch’s peak allocated / reserved; Apple has no such counter, so the Mac rows show the process footprint (weights, Python and torch included). “Output vs reference” compares the device’s output with the stored golden output under the card’s tolerance; – = not checked on that device. Kernels “not implemented” = no kernels for this model on that backend yet: it runs portable there.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 source
- Training data
-
- COCO 2017 (train, instance annotations) CC-BY-4.0
- ImageNet-1k (ILSVRC 2012 classification) noncommercial, non-commercial
Our reading of the licences, not legal advice.
Weights
detr-r50-e632da11.pth 167 MB· hosted on Meta (fbaipublicfiles)fastforks downloads and checks these files on first use (fastforks download detr-r50-coco).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
COCO val2017
every 10th image, box mAP
| Run | dtype | box mAP ↑ | Δ box mAP vs fp32 original | images | ms / image |
|---|---|---|---|---|---|
| Original fp32 | fp32 | 43.59 | reference | 500 | 45.7 |
| Original fp16 | fp16 | 43.53 | −0.06 | 500 | 38.7 |
| Portable fp32 | fp32 | 43.56 | −0.03 | 500 | 26.6 |
| Portable | fp16 | 43.59 | ±0.00 | 500 | 11.1 |
| Kernels | fp16 | 43.62 | +0.03 | 500 | 8.63 |
pycocotools COCOeval of the top 100 detections per image. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32, original fp16: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-06; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; portable, kernels: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 1.0 (absolute error of the output boxes).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.2 | 0.02003 |
| GPU default dtypes, p99 |diff| | ≤ 1 | 0.04454 |
Recorded for detr-r50-coco on RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-03, with these kernels: cudnn_hacc
Details
DETR (Carion et al. 2020, Facebook): end-to-end detection with a ResNet backbone and a 6+6 layer transformer encoder-decoder over 100 object queries, no NMS; boxes, scores and COCO classes at the input size. The portable `module()` is the whole network (class logits and normalised boxes).
- Input / output
- Input: one RGB image. Output: boxes, class labels, scores and instance masks.
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (599 MiB allocated)
- Options
score_threshold=0.050.0 to 1.0· changes the outputmax_detections=100>= 1· changes the output
- Outputs
boxes,scores,labels- Checkpoint
blocks=[3,4,6,3]- CUDA kernels
cudnn_haccconvolutions with fp16 accumulation (cuDNN)
- Apple (MPS)
- fp32, fp16
Full reference, generated from the repository
DETR (ResNet-50 and ResNet-101, COCO) from Facebook Research: end-to-end boxes and classes from 100 object queries, no NMS.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
detr-r50-coco | synthetic (800x1344) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 55.5 62.0 12.4 9.93 9.27 4.40 | 491 / 540 459 / 558 280 / 332 218 / 272 233 / 292 318 / 350 |
detr-r101-coco | synthetic (800x1344) | original (fp32) original portable kernels portable + torch.compile TensorRT fp16 | 78.9 80.8 18.7 13.7 14.7 6.60 | 564 / 634 531 / 650 316 / 368 254 / 328 272 / 330 377 / 440 |
Details
- Original code: https://github.com/facebookresearch/detr at
29901c51d7fe - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/facebookresearch/detr/blob/29901c51d7fe8712168b8d0d64351170bc0f83e0/README.md (License section)
- Training data: COCO 2017 (train, instance annotations), ImageNet-1k (ILSVRC 2012 classification) (COCO 2017 train (500 epochs); the ResNet backbone was initialised from torchvision's ImageNet-1k model)
- Options:
score_threshold= 0.05 (0.0 to 1.0),max_detections= 100 (>= 1) - Kernel libraries:
cudnn_hacc - Variants:
detr-r50-coco,detr-r101-coco - Outputs: boxes, scores, labels; label_set:
coco-80 - Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
detr-r50-coco3000x4000 (0.6 GiB peak allocated, 0.6 reserved);detr-r101-coco3000x4000 (0.6 GiB peak allocated, 0.7 reserved) detr-r50-coco800x1344, first call: portable + torch.compile 22 s (cold Inductor cache), TensorRT fp16 33 s (ONNX + engine).detr-r101-coco800x1344, first call: portable + torch.compile 18 s (cold Inductor cache), TensorRT fp16 35 s (ONNX + engine).detr-r50-cocooriginal (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)detr-r50-cocooriginal 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)detr-r101-cocooriginal (fp32) 800x1344: incl. CPU resize + host copy (official pipeline)detr-r101-cocooriginal 800x1344: torch.autocast(fp16) around the forward; incl. CPU resize + host copy (official pipeline)detr-r50-cocoload / first call: original 2.55 s / 0.827 s, portable 0.7 s / 0.439 s, kernels 0.28† s / 0.032 sdetr-r101-cocoload / first call: original 0.95 s / 0.063 s, portable 0.81 s / 0.019 s, kernels 0.22† s / 0.014 s- † measured in the speed sweep after the portable load (or an earlier size) in the same process: file cache and kernels are warm, so the time is lower than a fresh start.
- Protocol, median of 5 after 3 warm-up, uint8 CUDA input (synthetic for bench_inputs sizes), card defaults; gc before each load; peak = max over the first call and the timed calls
Measured
pycocotools COCOeval of the top 100 detections per image. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | portable fp32 | kernels | note |
|---|---|---|---|---|---|---|---|
detr-r50-coco | COCO val2017, every 10th image, box mAP | 43.59 | 43.53 | 43.59 | 43.56 | 43.62 | |
detr-r101-coco | COCO val2017, every 10th image, box mAP | 44.04 | 44.00 | 44.11 | 44.05 | 44.05 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 44640884, 2026-11-17; kernels: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 939adfe8, 2026-11-06.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.2 and p99 <= 1.0 (absolute error of the output boxes).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
detr-r50-coco | 0.02003 / 0.04454 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
detr-r101-coco | 0.03227 / 0.07451 | RTX 5060 Ti, torch 2.14.1+cu130 | cudnn_hacc@cudnn92400 |
Example output
One fixed input through this checkpoint, the same for every model of the task (kernels · float16 · NVIDIA GeForce RTX 5060 Ti).
- person 1.00
- cell phone 0.86
Input: Astronaut Eileen Collins, NASA (public domain).