Models · Object detection

D-FINE (HGNetV2, N / S / M / L / X)

D-FINE (N, S, M, L, X; HGNetV2, COCO) from USTC: real-time end-to-end detector in the RT-DETR style, 300 queries, deformable attention and box edges refined as distributions, no NMS. Commercially usable.

Commercial use: yes.

variantinputbackendtime (ms)peak memory (MiB, allocated / reserved)
dfine-n-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
portable + torch.compile
TensorRT fp16
24.3
29.1
10.3
2.72
5.43
0.942
91 / 122
92 / 126
88 / 116
124 / 202
101 / 118
56 (engine)
dfine-s-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
25.7
31.9
11.1
4.04
180 / 204
152 / 184
105 / 128
138 / 212
dfine-m-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
30.8
38.2
13.5
5.97
231 / 264
209 / 256
126 / 142
156 / 252
dfine-l-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
37.1
44.9
16.2
8.70
281 / 328
278 / 350
152 / 172
179 / 300
dfine-x-cocosynthetic (800x1344)original (fp32)
original
portable
kernels
44.9
54.6
18.5
14.1
452 / 488
476 / 536
227 / 258
237 / 364
Details
  • Original code: https://github.com/Peterande/D-FINE at 956d1709314c
  • Code licence: Apache-2.0 (permissive); files: LICENSE
  • Weights licence: Apache-2.0
  • Licence evidence: https://github.com/Peterande/D-FINE/blob/956d1709314c2c6a4df6f34de232054578a7449f/LICENSE
  • Training data: COCO 2017 (train, instance annotations), ImageNet-1k (ILSVRC 2012 classification) (COCO 2017 train; the HGNetV2 backbones start from ImageNet-1k pretraining)
  • Options: score_threshold = 0.05 (0.0 to 1.0), max_detections = 100 (>= 1), cuda_graphs = True (speed only)
  • Kernel libraries: cudnn_hacc
  • Variants: dfine-n-coco, dfine-s-coco, dfine-m-coco, dfine-l-coco, dfine-x-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): dfine-n-coco 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); dfine-s-coco 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); dfine-m-coco 3000x4000 (0.5 GiB peak allocated, 0.6 reserved); dfine-l-coco 3000x4000 (0.5 GiB peak allocated, 0.7 reserved); dfine-x-coco 3000x4000 (0.6 GiB peak allocated, 0.7 reserved)
  • dfine-n-coco 800x1344, first call: portable + torch.compile 27 s (cold Inductor cache), TensorRT fp16 52 s (ONNX + engine).
  • dfine-n-coco original (fp32) 800x1344: incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-n-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir); fp16 differs from the reference (box max diff 65.17 px)
  • dfine-s-coco original (fp32) 800x1344: incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-s-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-m-coco original (fp32) 800x1344: incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-m-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir); fp16 differs from the reference (detections 5 vs reference 4)
  • dfine-l-coco original (fp32) 800x1344: incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-l-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-x-coco original (fp32) 800x1344: incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-x-coco original 800x1344: torch.autocast(fp16) around the forward; incl. CPU PIL resize + host-to-device copy of the HF-transformers pipeline (the official D-FINE .pth is not in the weights dir)
  • dfine-n-coco load / first call: original 5.24 s / 4.072 s, portable 1.25 s / 0.853 s, kernels 1.21 s / 0.621 s
  • dfine-s-coco load / first call: original 2.99 s / 1.443 s, portable 1.05 s / 0.712 s, kernels 1.16 s / 0.523 s
  • dfine-m-coco load / first call: original 3.63 s / 1.546 s, portable 1.04 s / 0.69 s, kernels 1.2 s / 0.563 s
  • dfine-l-coco load / first call: original 3.68 s / 1.406 s, portable 1.09 s / 0.669 s, kernels 1.46 s / 0.47 s
  • dfine-x-coco load / first call: original 3.88 s / 1.452 s, portable 1.39 s / 0.654 s, kernels 1.41 s / 0.449 s
  • Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5

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).

variantkernels error vs original, mean / p99GPU, torchkernels used
dfine-n-coco0.1602 / 0.83664RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dfine-s-coco0.07327 / 0.23231RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dfine-m-coco0.05237 / 0.18261RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dfine-l-coco0.05001 / 0.13201RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400
dfine-x-coco0.04865 / 0.11921RTX 5060 Ti, torch 2.14.1+cu130cudnn_hacc@cudnn92400

Limitations

  • The original in the benchmarks and goldens is the Hugging Face transformers 5.19.0 port (DFineForObjectDetection, ustc-community weights) of the official D-FINE (Apache-2.0); the official repository code itself was not run.