← All models

object-detection Β· vision Β· WASM Β· ~10 MB

D-FINE β€” real-time detection that refines a distribution

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.

At a glance

Modelonnx-community/dfine_s_coco-ONNX (ONNX of ustc-community/dfine_s_coco)
Task / pipelineobject-detection (model_type d_fine, wired via the RTDetrImageProcessor)
ArchitectureHGNetv2 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
Classes80 COCO categories (person, car, dog, chair, bottle…)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~10 MB, cached after first load
LicenseApache-2.0 (D-FINE, USTC)
Web APIsWebAssembly, Web Workers, Canvas, getUserMedia, FileReader β€” all Baseline widely available

Run it

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.

Drop an image here, or click to choose
Two cats sleeping on a pink couch A cozy sunlit bedroom with a bookshelf A riverside at golden hour with a swan
0.50

See inside

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.

Run detection to see the raw boxes.

How D-FINE locates a box: FDR + GO-LSD

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.


Contrast β€” D-FINE vs RT-DETR (same family, sharper localisation)

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.

Why it matters

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.

Use cases

Basics

One image, labelled boxes, a threshold slider β€” feel SOTA real-time detection first-hand.

Practical

Inventory counter β€” pick a class and get a live running count with a photo tally log.

Wild

Crowded-scene webcam detector at the fastest loop your device sustains, with a still fallback.

Multi-model

D-FINE boxes β†’ crop each object β†’ ViT classifies it into 1,000 fine-grained labels.

How the API works

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.

References