DETR (ResNet-50 / ResNet-101) (fastforks)
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).
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/facebookresearch/detr at 29901c51d7fe.
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 |
|---|---|---|---|---|
detr-r101-coco@1 |
detr-r101-2c7b67e5.pth | 2c7b67e52d2e |
Apache-2.0 | yes |
detr-r50-coco@1 |
detr-r50-e632da11.pth | e632da11ec76 |
Apache-2.0 | yes |
Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Files: LICENSE.
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).
Licence evidence: https://github.com/facebookresearch/detr/blob/29901c51d7fe8712168b8d0d64351170bc0f83e0/README.md (License section)
Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): detr-r101-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved); detr-r50-coco 3000x4000 (0.6 GiB peak allocated, 0.6 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 |
|---|---|---|---|---|---|---|---|---|---|
detr-r101-coco |
78.9 | 80.8 | 18.69 | 13.69 | 5.8x | 1.4x | 531 / 650 | 316 / 368 | 254 / 328 |
detr-r50-coco |
55.5 | 62.0 | 12.36 | 9.93 | 5.6x | 1.2x | 459 / 558 | 280 / 332 | 218 / 272 |
Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
|---|---|---|---|---|---|---|
detr-r101-coco |
0.95 | 0.81 | 0.22โ | 0.06 | 0.02 | 0.01 |
detr-r50-coco |
2.55 | 0.70 | 0.28โ | 0.83 | 0.44 | 0.03 |
Fixed-size speed and peak memory, all models
| model | mode | 640x480 | 1280x720 | 1920x1080 | 12 MP 4000x3000 |
|---|---|---|---|---|---|
detr-r101-coco |
portable | 14.4 ms / 278 / 332 | 17.6 ms / 307 / 356 | 18.3 ms / 320 / 416 | 23.8 ms / 636 / 676 |
detr-r101-coco |
kernels | 10.5 ms / 228 / 278 | 13.0 ms / 248 / 294 | 13.3 ms / 262 / 354 | 19.8 ms / 637 / 678 |
detr-r50-coco |
portable | 9.5 ms / 241 / 296 | 11.6 ms / 270 / 320 | 12.2 ms / 283 / 380 | 18.7 ms / 599 / 640 |
detr-r50-coco |
kernels | 7.7 ms / 191 / 240 | 8.9 ms / 211 / 256 | 9.8 ms / 225 / 316 | 16.7 ms / 600 / 640 |
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("detr-r101-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: detr-r101-coco, detr-r50-coco.
Kernels backend
detection.load("detr-r101-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.