At a glance
| Upstream model | PekingU/rtdetr_v2_r50vd (Lv et al. 2024, arXiv:2407.17140) |
|---|---|
| Browser ONNX repo | onnx-community/rtdetr_v2_r50vd-ONNX → onnx/model_quantized.onnx |
| Pipeline task | object-detection (Transformers.js pipeline("object-detection", "onnx-community/rtdetr_v2_r50vd-ONNX")) |
| Architecture | RtDetrV2ForObjectDetection (rt_detr_v2): ResNet-50-vd (depths: [3, 4, 6, 3]) → hybrid encoder (strides [8, 16, 32]) → 6-layer selective multi-scale discrete sampling decoder (3 levels, 4 points, 300 queries, 640×640 input) |
| Output shape | Array of { label, score, box: { xmin, ymin, xmax, ymax } } in pixel coordinates (percentage: false) — NMS-free one-to-one set prediction |
| Quantization & size | q8: 44.33 MB (44,326,915 B; fp16 86.48 MB · fp32 172.31 MB not used here) |
| Runtime & backend | Shared lib/webai.js Transformers.js 3.7.5 · CPU WASM in a module Web Worker (no WebGPU required) |
| Labels | 80 COCO classes, preserving checkpoint spellings (sofa, tvmonitor, diningtable, pottedplant, motorbike, aeroplane) |
| License | Apache-2.0 |
Live detection lab
One forward pass collects every candidate scoring ≥ 0.15, so dragging the confidence slider
or toggling class groups re-filters the cached detections immediately without re-running the worker.
Loading a curated zero-person scene…
Select a box to inspect its query rank, stride level, and pixel coordinates.
| Feature stride | 640×640 footprint | Active boxes | Mean score |
|---|---|---|---|
| Run the detector to inspect feature-scale allocation. | |||
| Class | Group | Count | Best score | Mean score |
|---|---|---|---|---|
| Run the detector to fill this table. | ||||
| Query rank | Class | Score | Scale / stride | Box [x1, y1, x2, y2] | Size |
|---|---|---|---|---|---|
| No detections yet. | |||||
See inside — discrete sampling & selective multi-scale queries
In RT-DETR v1, deformable cross-attention relied on continuous bilinear grid_sample across
encoder feature maps, which triggers custom-op fallbacks or precision drift in quantized ONNX runtimes.
RT-DETRv2 replaces that operator with discrete sampling
(disable_custom_kernels: true, decoder_n_levels: 3, decoder_n_points: 4)
and tunes per-scale sampling point budgets across the ResNet-50-vd strides ([8, 16, 32])
together with a bag-of-freebies training recipe (dynamic augmentation and scale-adaptive hyperparameters).
Combined with one-to-one Hungarian matching across 300 queries, RT-DETRv2 keeps the exact same inference budget as RT-DETR R50vd (44.33 MB vs 45.46 MB q8) while improving small-object localisation and ONNX portability.
Show the code — epoch-guarded pipeline load in the Web Worker
Show the code — mapping each box to its RT-DETRv2 hybrid-encoder stride
Use-case ladder
Basics
Explore discrete multi-scale sampling vs v1, sweep thresholds 0.15→0.85, ablate top-K queries, and inspect scale/aspect splits.
Practical
Queue curated zero-person scenes or your own photos in strict FIFO order, check target inventories, cancel mid-batch, and export CSV/JSON.
Wild
Run scale downscale, centre crop, defocus blur, low-light contrast, and JPEG compression probes measuring live IoU and confidence drift.
Multi-model
Race RT-DETRv2 R50vd head-to-head against RT-DETR v1 R50vd on the same image to measure box IoU and small-object parity.
How the API works
import { TRANSFORMERS_URL } from "/lib/webai.js"; // Transformers.js 3.7.5
const { pipeline } = await import(TRANSFORMERS_URL);
const detector = await pipeline("object-detection", "onnx-community/rtdetr_v2_r50vd-ONNX", {
dtype: "q8", // onnx/model_quantized.onnx, 44.33 MB
device: "wasm", // CPU WebAssembly inside a module Worker
});
const boxes = await detector(image, { threshold: 0.15, percentage: false });
// → [{ label: "bed", score: 0.94, box: { xmin, ymin, xmax, ymax } }, …] — NMS-free