object-detection Β· vision Β· WASM Β· ~21 MB
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.
| Model | onnx-community/rtdetr_v2_r18vd-ONNX (ONNX of PekingU/rtdetr_v2_r18vd) |
|---|---|
| Task / pipeline | object-detection |
| Architecture | ResNet-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 v1 | Decoder sampling points selectable per scale; grid_sample β discrete sampling (clean ONNX export); bag-of-freebies training β better accuracy at the same speed & size |
| Classes | 80 COCO categories (person, car, dog, chair, bottleβ¦) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~21 MB, cached after first load |
| License | Apache-2.0 (Baidu RT-DETR) |
| 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. RT-DETRv2 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.
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.
| # | label | score | x | y | w | h |
|---|
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.
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.
One image, labelled boxes, a threshold slider β feel the improved detector first-hand.
Inventory & occupancy β pick a class and get a running count, per-class tally, and CSV.
Crowd counter β how many people in a dense scene, plus a live webcam loop.
RT-DETRv2 boxes β tap one β ViT classifies the crop into a fine-grained label.
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.