StagesDetect

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

ParameterTypeDefaultMeaning
modelstring''Hugging Face repo id, or a URL when self-hosting. No default.
labelsstring[][]Class index → label. Empty falls back to class_<n>.
scoreThresholdnumber 0–10.2Drop detections below this confidence.
iouThresholdnumber 0–10.5Overlap above which two same-class boxes count as duplicates.
paddingnumber 0–10Grow each box by this fraction of its size, to avoid clipping edges.

On this page