Grounding DINO and MM-Grounding-DINO (open-vocabulary, Swin-T and Swin-B)
IDEA Research's Grounding DINO and OpenMMLab's MM-Grounding-DINO (tiny, base; Swin backbone, BERT text encoder): open-vocabulary detector, finds boxes for class names given as text at call time (default: the 80 COCO classes). Apache-2.0 code and weights.
experimental Fork of huggingface/transformers@c4c4605 · backends: portable, kernels
- Paper Grounding DINO: Marrying DINO with Grounded Pre-Training for Open-Set Object Detection ECCV 2024 · first released 9 Mar 2023
- Authors’ code IDEA-Research/GroundingDINO (PyTorch), not the code forked here: fastforks follows the Hugging Face transformers port, which loads the IDEA-Research/grounding-dino-* weights, instead of the authors' repository.
- Authors’ code open-mmlab/mmdetection (PyTorch), not the code forked here: The MM-Grounding-DINO authors' code lives in MMDetection; fastforks follows the Hugging Face transformers port that loads the converted weights.
Paper 2023 Added in 0.2.0 Evaluated with 0.2.0
Use it
pip install fastforks Lean install with only what this model needs: pip install "fastforks-core[transformers]"
from fastforks import detection
model = detection.load("grounding-dino-tiny") # 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 grounding-dino-tiny 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 fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original fp16torch.autocast(float16) around the call; transformers GroundingDinoForObjectDetection + processor (CPU), coco-80 caption, text tower per call | fp16 | 199 | – | 2,541 MiB/2,716 MiB | 1.4 | 0.34 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 138 | 1.4× | 1,404 MiB/1,468 MiB | 3.0 | 0.51 |
| Kernels | not measured | – | – | – | – | |
| Portable + torch.compile | 111 | 1.8× | 2,550 MiB/2,664 MiB | 73 (build) | – | |
| TensorRTplanned for 0.2.1 | fails | – | – | – | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-12. First call, 3 warm-up, peak reset, median of 3 rounds x median of 5. 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-13 | Original | fp32 | 912 | 4,899 MiB process | – | 800x1344 |
| Portable | fp32 | 846 | 4,787 MiB process | matches | 800x1344 | |
| Kernels | fp32 | not implemented | – | 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
- Weights
- Apache-2.0 source
- Training data
-
- Objects365 (train, box annotations) CC-BY-4.0, non-commercial
Our reading of the licences, not legal advice.
Weights
gdino-tiny.config.json 1.6 KB· hosted on Hugging Facegdino-tiny.model.safetensors 689 MB· hosted on Hugging Facebert-uncased.vocab.txt 232 KB· hosted on Hugging Facefastforks downloads and checks these files on first use (fastforks download grounding-dino-tiny).
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 | 51.08 | reference | 500 | – |
| Original fp16 | fp16 | 51.16 | +0.08 | 500 | – |
| Portable fp32 | fp32 | 51.12 | +0.04 | 500 | – |
| Portable | fp16 | 51.14 | +0.06 | 500 | – |
| Kernels | not measured | ||||
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-12; portable fp32: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 9e3ff83d+dir, 2026-11-17; portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks a981ff86, 2026-11-12.
COCO val2017
all 5000 images, box mAP
| Run | dtype | box mAP ↑ | Δ box mAP vs fp32 original | images | ms / image |
|---|---|---|---|---|---|
| Original fp32 | fp32 | 48.25 | reference | 5000 | – |
| Original fp16 | not measured | ||||
| Portable fp32 | not measured | ||||
| Portable | fp16 | 48.25 | ±0.00 | 5000 | – |
| Kernels | not measured | ||||
pycocotools COCOeval of the top 100 detections per image. Original = the authors’ code, same checkpoint and protocol. Measured on original fp32: RTX 5060 Ti, torch 2.14.1+cu130, 2026-11-12; portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 84ba91d4, 2026-11-12.
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.25 and p99 <= 0.8 (absolute error of the output boxes).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.002 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.25 | 0.12884 |
| GPU default dtypes, p99 |diff| | ≤ 0.8 | 0.53156 |
Recorded for grounding-dino-tiny on RTX 5060 Ti, torch 2.10.0+cu130, 2026-11-17, with these kernels: msda
Details
Grounding DINO (Liu et al. 2023, IDEA Research): open-set detection that fuses a Swin image backbone with a BERT text encoder in a DINO-style deformable transformer; each of 900 queries scores every caption token. MM-Grounding-DINO (Zhao et al. 2024, OpenMMLab) is the same network with a scaled, biased contrastive class head and unshared decoder heads, retrained on Objects365, GoldG and V3Det. Pass `text=[...]` at call time (default: the 80 COCO class names), joined into one caption; a class score is the mean token score of its name. Images are resized to 800 px on the short side (at most 1333 on the long side). The portable `module()` is the image side with the COCO caption's text features as constants.
- 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 (1,373 MiB allocated)
- Options
score_threshold=0.250.0 to 1.0· changes the outputmax_detections=100>= 1· changes the output
- Outputs
boxes,scores,labels- CUDA kernels
msda
- Apple (MPS)
- fp32
Limitations
- Requires the optional transformers library (the network is its `GroundingDinoForObjectDetection`).
- The original in the benchmarks and goldens is the Hugging Face transformers 5.19.0 port with the authors' weights (IDEA-Research/grounding-dino-*, openmmlab-community/mm_grounding_dino_*); the official GroundingDINO and mmdetection code (their CUDA deformable-attention ops) was not run.
- Class names are joined into one caption of at most 256 tokens (about 100 short names); a longer list raises an error instead of being split into several passes.
- No phrase output: `labels` index into the given names (the token-level text threshold of the Hugging Face post-processing is not used).
- grounding-dino-base was trained with COCO (and RefCOCO, ODinW) data: its COCO numbers are not zero-shot.
Full reference, generated from the repository
IDEA Research's Grounding DINO and OpenMMLab's MM-Grounding-DINO (tiny, base; Swin backbone, BERT text encoder): open-vocabulary detector, finds boxes for class names given as text at call time (default: the 80 COCO classes). Apache-2.0 code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
grounding-dino-tiny | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 199 138 – 111 planned for 0.2.1 | 2541 / 2716 1404 / 1468 – 2550 / 2664 – |
grounding-dino-base | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 230 160 – 131 planned for 0.2.1 | 2895 / 3094 1525 / 1624 – 2669 / 2800 – |
mm-grounding-dino-tiny | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 202 138 – 111 planned for 0.2.1 | 2541 / 2716 1405 / 1470 – 2555 / 2666 – |
mm-grounding-dino-base | synthetic (800x1344) | original portable kernels portable + torch.compile TensorRT fp16 | 232 160 – 132 planned for 0.2.1 | 2895 / 3094 1525 / 1624 – 2669 / 2800 – |
Details
- Original code: https://github.com/huggingface/transformers at
c4c4605f9618 - Code licence: Apache-2.0 (permissive); files:
- Weights licence: Apache-2.0
- Licence evidence: https://huggingface.co/IDEA-Research/grounding-dino-tiny/blob/a2bb814dd30d776dcf7e30523b00659f4f141c71/README.md
- Training data: Objects365 (train, box annotations) (Grounding DINO-T: Objects365, GoldG (Flickr30k Entities + GQA / Visual Genome images) and Cap4M (web image-caption pairs with pseudo-boxes); GoldG and Cap4M have no dataset id here (paper arXiv:2303.05499 table 2; the authors' model table).)
grounding-dino-base: COCO 2017 (train, instance annotations), Objects365 (train, box annotations) (Grounding DINO-B: COCO, Objects365, GoldG (Flickr30k Entities + GQA / Visual Genome images), Cap4M (web image-caption pairs with pseudo-boxes), OpenImages, ODinW-35 and RefCOCO; only COCO and Objects365 have dataset ids here (the authors' model table, github.com/IDEA-Research/GroundingDINO README).)mm-grounding-dino-tiny: Objects365 (train, box annotations) (MM-Grounding-DINO-T (o365v1_goldg_v3det): Objects365 v1, GoldG (Flickr30k Entities + GQA / Visual Genome images) and V3Det; no COCO, so its COCO numbers are zero-shot (mmdetection configs/mm_grounding_dino README; paper arXiv:2401.02361).)mm-grounding-dino-base: Objects365 (train, box annotations) (MM-Grounding-DINO-B (o365v1_goldg_v3det): Objects365 v1, GoldG (Flickr30k Entities + GQA / Visual Genome images) and V3Det; no COCO, so its COCO numbers are zero-shot (mmdetection configs/mm_grounding_dino README; paper arXiv:2401.02361).)
- Options:
score_threshold= 0.25 (0.0 to 1.0),max_detections= 100 (>= 1) - Kernel libraries:
msda - Variants:
grounding-dino-tiny,grounding-dino-base,mm-grounding-dino-tiny,mm-grounding-dino-base - Not in this release (planned for 0.2.1):
grounding-dino-tinyONNX / TensorRT export: the ONNX converter has no decomposition for aten._is_all_true;grounding-dino-basekernels: the pinned upstream CPU model and portable runner both exceed the existing Base box tolerance;grounding-dino-baseONNX / TensorRT export: the ONNX converter has no decomposition for aten._is_all_true;mm-grounding-dino-tinyONNX / TensorRT export: the ONNX converter has no decomposition for aten._is_all_true;mm-grounding-dino-baseONNX / TensorRT export: the ONNX converter has no decomposition for aten._is_all_true - 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):
grounding-dino-tiny3000x4000 (1.3 GiB peak allocated, 1.5 reserved);grounding-dino-base3000x4000 (1.5 GiB peak allocated, 1.7 reserved);mm-grounding-dino-tiny3000x4000 (1.3 GiB peak allocated, 1.5 reserved);mm-grounding-dino-base3000x4000 (1.5 GiB peak allocated, 1.7 reserved) grounding-dino-tiny800x1344, first call: portable + torch.compile 73 s (cold Inductor cache).grounding-dino-base800x1344, first call: portable + torch.compile 98 s (cold Inductor cache).mm-grounding-dino-tiny800x1344, first call: portable + torch.compile 71 s (cold Inductor cache).mm-grounding-dino-base800x1344, first call: portable + torch.compile 105 s (cold Inductor cache).grounding-dino-tinyoriginal 800x1344: torch.autocast(float16) around the call; transformers GroundingDinoForObjectDetection + processor (CPU), coco-80 caption, text tower per callgrounding-dino-baseoriginal 800x1344: torch.autocast(float16) around the call; transformers GroundingDinoForObjectDetection + processor (CPU), coco-80 caption, text tower per callmm-grounding-dino-tinyoriginal 800x1344: torch.autocast(float16) around the call; transformers MMGroundingDinoForObjectDetection + processor (CPU), coco-80 caption, text tower per callmm-grounding-dino-baseoriginal 800x1344: torch.autocast(float16) around the call; transformers MMGroundingDinoForObjectDetection + processor (CPU), coco-80 caption, text tower per callgrounding-dino-tinyload / first call: original 4.06 s / 1.176 s, portable 3.01 s / 0.508 sgrounding-dino-baseload / first call: original 4.16 s / 0.989 s, portable 3.29 s / 0.527 smm-grounding-dino-tinyload / first call: original 4.17 s / 0.99 s, portable 3.26 s / 0.517 smm-grounding-dino-baseload / first call: original 4.1 s / 1.029 s, portable 3.33 s / 0.527 s- Protocol, first call, 3 warm-up, peak reset, median of 3 rounds x median of 5
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 | note |
|---|---|---|---|---|---|---|
grounding-dino-tiny | COCO val2017, every 10th image, box mAP | 51.08 | 51.16 | 51.14 | 51.12 | |
grounding-dino-tiny | COCO val2017, all 5000 images, box mAP | 48.25 | 48.25 | |||
grounding-dino-base | COCO val2017, every 10th image, box mAP | 55.67 | 55.73 | 55.72 | 57.13 | |
mm-grounding-dino-tiny | COCO val2017, every 10th image, box mAP | 51.49 | ||||
mm-grounding-dino-tiny | COCO val2017, every 20th image, box mAP | 55.18 | 54.92 | |||
mm-grounding-dino-base | COCO val2017, every 10th image, box mAP | 53.01 | ||||
mm-grounding-dino-base | COCO val2017, every 20th image, box mAP | 57.11 | 56.94 |
Measured on portable: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 84ba91d4 / a981ff86 / aee4b565, 2026-11-12 to 2026-11-13; portable32: NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 9e3ff83d+dirty, 2026-11-17.
Parity
CPU, float32: max |diff| <= 0.002 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.25 and p99 <= 0.8 (absolute error of the output boxes).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
grounding-dino-tiny | 0.12884 / 0.53156 | RTX 5060 Ti, torch 2.10.0+cu130 | msda@7db8a6f4e515:sm_120 |
grounding-dino-base | no kernels backend | - | - |
mm-grounding-dino-tiny | 0.08186 / 0.19259 | RTX 5060 Ti, torch 2.10.0+cu130 | msda@7db8a6f4e515:sm_120 |
mm-grounding-dino-base | 0.08714 / 0.23686 | RTX 5060 Ti, torch 2.10.0+cu130 | msda@7db8a6f4e515:sm_120 |
Limitations
- Requires the optional transformers library (the network is its
GroundingDinoForObjectDetection). - The original in the benchmarks and goldens is the Hugging Face transformers 5.19.0 port with the authors' weights (IDEA-Research/grounding-dino-, openmmlab-community/mm_grounding_dino_); the official GroundingDINO and mmdetection code (their CUDA deformable-attention ops) was not run.
- Class names are joined into one caption of at most 256 tokens (about 100 short names); a longer list raises an error instead of being split into several passes.
- No phrase output:
labelsindex into the given names (the token-level text threshold of the Hugging Face post-processing is not used). - grounding-dino-base was trained with COCO (and RefCOCO, ODinW) data: its COCO numbers are not zero-shot.
Example output
No example rendered for this checkpoint yet.