YoloOnnxDetector
Any YOLO ONNX graph as a pipeline stage — bring your own model and labels.
- Import
import { YoloOnnxDetector } from '@stabrise/scaledp/detect'- Group
- Detect
- Reads
- image
- Writes
- boxes
- Needs
onnxruntime-web
The general object detector. SignatureDetector and FaceDetector are this
class with a model and labels pre-set; anything else you have as a YOLO ONNX
export goes here.
import { Pipeline } from '@stabrise/scaledp'
import { PdfToImage } from '@stabrise/scaledp/pdf'
import { YoloOnnxDetector } from '@stabrise/scaledp/detect'
const rows = await new Pipeline([
new PdfToImage(),
new YoloOnnxDetector({
model: 'my-org/stamp-detection',
labels: ['stamp', 'seal'],
scoreThreshold: 0.35,
outputCol: 'stamps',
outputType: 'stamp',
}),
]).transform(file)model is required — an empty one throws RangeError('model is required')
from the constructor. labels maps class index to name; leave it empty and
classes come back as class_0, class_1.
What it accepts
The input size is read off the graph, falling back to 960. Both common output
layouts are decoded: [1, 4 + numClasses, anchors] (YOLOv8/v11, transposed) and
[1, N, 6] (a graph with NMS already baked in).
Letterboxing is centred here, and there is no mean/std normalisation — which
is the opposite of DbnetOnnxDetector
on both counts. Each detector's preprocessing matches the model it was trained
with.
padding grows each box by a fraction of its own size, which is usually what you
want before cropping a signature out for storage.
The pieces, separately
import { decodeYoloOutput, iou, nonMaximumSuppression } from '@stabrise/scaledp/detect'Exported for anyone wiring a YOLO graph up by hand. NMS is per class.
A Python bug not reproduced
ScaleDP's YoloOnnxTextDetector multiplies by the letterbox scale where DBNet
divides. Coordinates here are mapped back correctly.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
model | string | '' | Hugging Face repo id, or a URL when self-hosting. No default. |
labels | string[] | [] | Class index → label. Empty falls back to class_<n>. |
scoreThreshold | number 0–1 | 0.2 | Drop detections below this confidence. |
iouThreshold | number 0–1 | 0.5 | Overlap above which two same-class boxes count as duplicates. |
padding | number 0–1 | 0 | Grow each box by this fraction of its size, to avoid clipping edges. |