At a glance
| Upstream model | PekingU/rtdetr_r50vd (Baidu RT-DETR, Zhao et al. 2023) |
|---|---|
| Browser ONNX repo | onnx-community/rtdetr_r50vd β onnx/model_quantized.onnx |
| Pipeline task | object-detection (Transformers.js pipeline("object-detection", "onnx-community/rtdetr_r50vd")) |
| Architecture | RTDetrForObjectDetection (rt_detr): ResNet-50-vd β hybrid encoder (AIFI + CCFM) β uncertainty-minimal query selection β 6-layer decoder, 300 queries, 640Γ640 input |
| Output | Per query: 80 sigmoid class scores + one box; the pipeline keeps { label, score, box: { xmin, ymin, xmax, ymax } } above the threshold β no NMS |
| Quantization & size | q8: 45.46 MB (fp16 87.98 MB Β· fp32 175.42 MB not used here) |
| Runtime & backend | Shared lib/webai.js Transformers.js 3.7.5 Β· CPU WASM in a module Web Worker (no WebGPU needed) |
| Labels | 80 COCO classes, using the checkpoint's own spellings (sofa, tvmonitor, diningtable, pottedplant, motorbike, aeroplane) |
| License | Apache-2.0 |
Live object detector
One forward pass keeps every candidate scoring β₯ 0.15, so the confidence slider and class
filters re-filter instantly without re-running the model. Click or Tab to any box to inspect it.
Loading a sample photoβ¦
Select a box to see its exact coordinates.
| Class | Group | Count | Best score | Mean score |
|---|---|---|---|---|
| Run the detector to fill this table. | ||||
| # | Class | Score | Box [x1, y1, x2, y2] | Size |
|---|---|---|---|---|
| No detections yet. | ||||
See inside β why there is no NMS step
Classic detectors emit thousands of overlapping candidates and rely on non-maximum suppression (NMS)
to delete duplicates afterwards. RT-DETR is trained with one-to-one Hungarian matching:
each ground-truth object is assigned to exactly one of the 300 decoder queries, and every other query
is pushed towards "no object". The model therefore learns to emit one box per object by itself. The
Same-class dupes metric above re-checks that claim live: it counts same-label box pairs that
overlap with IoU > 0.5 β the boxes an NMS pass would have deleted. Expect zero or a stray pair: on
the bedroom sample at 0.40 one near-identical sofa pair (53% / 49%, IoU 0.99) survives,
and lowering the threshold to 0.15 surfaces many more weak duplicates β the Basics rung's overlap audit explores exactly where that line sits.
The hybrid encoder applies self-attention only to the coarsest (stride-32) feature map (AIFI) and fuses scales with convolutions (CCFM), which is what makes a DETR fast enough for real time. Uncertainty-minimal query selection then picks the 300 encoder tokens whose classification and localisation agree best as the decoder's starting queries.
Show the code β epoch-guarded pipeline load in the Web Worker
Show the code β NMS-free duplicate-overlap audit
Why RT-DETR R50vd matters
- End-to-end detection β no anchor tuning, no NMS threshold to pick, no post-processing that can silently merge two adjacent people.
- Transformer accuracy at CNN speed β the paper reports 53.1 COCO AP for R50 at real-time GPU speed; here the same graph runs on a plain CPU through WebAssembly.
- Private by construction β 45.46 MB is cached once in Cache Storage and every later visit initialises automatically, offline.
Use-case ladder
Basics
Sweep the threshold from 0.15 to 0.85, audit duplicate overlaps, and break detections down by small / medium / large area.
Practical
Queue many photos, count an inventory against a target checklist, and export formula-safe CSV or COCO JSON.
Wild
Draw a zone on a live webcam feed or a photo and raise alerts when COCO classes enter it β all on-device.
Multi-model
RT-DETR finds the objects, then a ViT-B/16 ImageNet classifier names each crop more finely.
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_r50vd", {
dtype: "q8", // onnx/model_quantized.onnx, 45.46 MB
device: "wasm", // CPU WebAssembly, inside a Web Worker
});
const boxes = await detector(image, { threshold: 0.15, percentage: false });
// β [{ label: "chair", score: 0.54, box: { xmin, ymin, xmax, ymax } }, β¦] β no NMS required