← All models

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

RT-DETRv2 β€” the improved real-time detector

RT-DETRv2 is RT-DETR, refined. Same ResNet-18 backbone, same 80 COCO classes, same NMS-free, one-pass, real-time design β€” but the decoder is redesigned: its sampling points are selectable per feature scale (a "flexible decoder"), and the internal grid_sample is swapped for a discrete sampling operator that exports and deploys cleanly. Trained with a bag-of-freebies recipe, it lands cleaner, better-localised boxes at the same inference cost as v1. Race the two side by side, all on your device.

At a glance

Modelonnx-community/rtdetr_v2_r18vd-ONNX (ONNX of PekingU/rtdetr_v2_r18vd)
Task / pipelineobject-detection
ArchitectureResNet-18 backbone + efficient hybrid encoder + flexible (selective multi-scale) decoder with discrete sampling β€” an end-to-end, NMS-free real-time DETR (model_type rt_detr_v2, 3 decoder layers)
What changed vs v1Decoder sampling points selectable per scale; grid_sample β†’ discrete sampling (clean ONNX export); bag-of-freebies training β€” better accuracy at the same speed & size
Classes80 COCO categories (person, car, dog, chair, bottle…)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~21 MB, cached after first load
LicenseApache-2.0 (Baidu RT-DETR)
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. RT-DETRv2 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 busy crowd of people Athletes playing on a field A cozy sunlit bedroom with a bookshelf A riverside at golden hour with a swan
0.50

See inside

RT-DETRv2's decoder emits a fixed set of predictions each pass β€” one per query β€” and, unlike anchor detectors, it does not run a non-maximum-suppression pass to merge overlapping boxes. 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.

Head-to-head β€” RT-DETRv2 vs RT-DETR v1 (same backbone, same size)

This is the honest comparison. Both are r18vd (ResNet-18, ~21–22 MB, NMS-free, real-time) β€” so it is not a size or speed story like v1 vs heavy DETR. The only difference is the decoder redesign and training recipe. Run RT-DETR v1 on the current image and compare, box for box, at your chosen threshold: how many objects each keeps, and how their confidences line up. Loading v1 downloads its own ~22 MB the first time.

Why it matters

RT-DETRv2 is the drop-in upgrade for anyone already using a real-time DETR: same size, same latency budget, same one-call API β€” but a decoder that localises more cleanly and a discrete sampling operator that exports to ONNX without the deployment friction of grid_sample. In the browser that last point matters: it is exactly why this q8 build runs in a tab at all.

Use cases

Basics

One image, labelled boxes, a threshold slider β€” feel the improved detector first-hand.

Practical

Inventory & occupancy β€” pick a class and get a running count, per-class tally, and CSV.

Wild

Crowd counter β€” how many people in a dense scene, plus a live webcam loop.

Multi-model

RT-DETRv2 boxes β†’ tap one β†’ ViT classifies the crop into a fine-grained label.

How the API works

Detection is a one-liner with Transformers.js β€” RT-DETRv2 uses the same object-detection pipeline as v1; only the model id changes:

import { pipeline } from "@huggingface/transformers";

const detect = await pipeline(
  "object-detection",
  "onnx-community/rtdetr_v2_r18vd-ONNX",   // ← v2 build; drop-in for rtdetr_r18vd (v1)
  { dtype: "q8" },                         // ~21 MB, cached after first load
);

const output = await detect(imageURL, { threshold: 0.5, percentage: false });
// β†’ [{ label: "cat", score: 0.97, 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