object-detection Β· vision Β· WASM Β· ~10 MB
D-FINE is a state-of-the-art real-time detector. It keeps RT-DETR's fast, NMS-free, one-pass design β but changes how a box is located: instead of regressing four raw coordinates, it predicts a probability distribution for each box edge and sharpens it layer by layer, then distils that refined localisation back into the earlier layers. The payoff is higher COCO accuracy than RT-DETR at the same speed β small enough (~10 MB) to run your webcam. All on your device.
| Model | onnx-community/dfine_s_coco-ONNX (ONNX of ustc-community/dfine_s_coco) |
|---|---|
| Task / pipeline | object-detection (model_type d_fine, wired via the RTDetrImageProcessor) |
| Architecture | HGNetv2 backbone + efficient hybrid encoder + RT-DETR decoder, with Fine-grained Distribution Refinement (FDR) box heads and GO-LSD self-distillation β end-to-end, NMS-free |
| Classes | 80 COCO categories (person, car, dog, chair, bottleβ¦) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~10 MB, cached after first load |
| License | Apache-2.0 (D-FINE, USTC) |
| Web APIs | WebAssembly, Web Workers, Canvas, getUserMedia, FileReader β all Baseline widely available |
Pick or drop an image and hit Detect β or start the webcam and watch it box the world in real time. D-FINE runs once at a low floor; the score slider then filters the boxes live without re-running the model.
This device or context didn't grant camera access. The model still works on stills β pick a sample above and Detect.
D-FINE's decoder emits a fixed set of predictions each pass β one per query β with no
non-maximum-suppression. The list below is what the model returned directly: label,
softmax confidence, and box as x, y, width, height in the image's own pixels,
filtered only by your score slider.
| # | label | score | x | y | w | h |
|---|
A normal detector head regresses four numbers per box β x, y, w, h β as point estimates. D-FINE instead predicts, for each of the four edges, a probability distribution over a set of discretized offsets, and the decoder layers iteratively refine those distributions (Fine-grained Distribution Refinement). A sharp, single-peaked distribution means a confident edge; a spread-out one means the model is unsure where the boundary is. Then GO-LSD (Global Optimal Localization Self-Distillation) distils the final, best-refined distributions back into the earlier layers during training β so the network localises better with zero extra cost at inference. That is the accuracy edge over RT-DETR, at the same real-time latency.
D-FINE is built on the RT-DETR decoder, so this is the fairest head-to-head: same NMS-free, real-time design, but D-FINE's distribution heads push COCO accuracy up. Published COCO AP: D-FINE-S β 48.5 vs RT-DETR-R18 β 46.5 (from the D-FINE paper). Latency below is measured live on your device β loading RT-DETR downloads ~22 MB the first time.
D-FINE is the current sweet spot for detection you can run every frame: RT-DETR's speed with a measurable accuracy bump and no NMS to tune. It turns "what's in this video, right now?" into a local function call β private, offline, free per call β at a ~10 MB download.
One image, labelled boxes, a threshold slider β feel SOTA real-time detection first-hand.
Inventory counter β pick a class and get a live running count with a photo tally log.
Crowded-scene webcam detector at the fastest loop your device sustains, with a still fallback.
D-FINE boxes β crop each object β ViT classifies it into 1,000 fine-grained labels.
Detection is a one-liner with Transformers.js β D-FINE uses the same object-detection pipeline as DETR and RT-DETR:
import { pipeline } from "@huggingface/transformers";
const detect = await pipeline(
"object-detection",
"onnx-community/dfine_s_coco-ONNX",
{ dtype: "q8" }, // ~10 MB, cached after first load
);
const output = await detect(imageURL, { threshold: 0.5, percentage: false });
// β [{ label: "cat", score: 0.98, box: { xmin, ymin, xmax, ymax } }, β¦]
// NMS-free: the boxes are already de-duplicated β no suppression pass needed.
// percentage:false gives pixel coordinates; true gives 0β1 fractions
This page runs the model once at a low floor threshold (0.05) inside a Web Worker, caches every box, and filters the cached list as you drag the slider β so the slider is instant and never re-runs inference. The webcam loop grabs a frame, detects it, and only schedules the next after the last finishes, so it never piles up work or blocks the page.