object-detection (text) Β· vision Β· WASM Β· ~2.4 MB
A text detector doesn't read words β it finds where they are. This PaddleOCR DBNet model turns a photo into a per-pixel "is this text?" probability map, then decodes that map into oriented boxes around every text region β a receipt's line items, a shop sign, angled poster type. It runs entirely on your device via ONNX Runtime Web; the image and the boxes never leave the tab. Detection locates text; reading it is a separate step (see the multi-model demo).
| Model | breezedeus/cnstd-ppocr-en_PP-OCRv3_det β PaddleOCR PP-OCRv3 detection (DBNet) |
|---|---|
| Task | object-detection (text-region detection) β run via raw ONNX Runtime Web (see note below) |
| Runtime | onnxruntime-web 1.21 (transformers.js has no DBNet text-detection class) |
| Input | [1, 3, H, W] NCHW β the image resized so H,W are multiples of 32, ImageNet-normalised |
| Output | [1, 1, H, W] β a per-pixel text-probability map; decoded (threshold β connected components β min-area box) into region polygons |
| Quantization | fp32 ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~2.4 MB, cached after first load |
| License | Apache-2.0 (ONNX export) Β· PaddleOCR (Apache-2.0) |
| Web APIs | WebAssembly, Web Workers, OffscreenCanvas, Canvas β all Baseline widely available |
Pick a sample (or drop your own image), then detect. The model returns oriented boxes around every text region β it does not read the words.
βtext regions found
Everything runs on your device β the image, the probability map, and the boxes never leave the tab. The samples are generated for this demo (no real people or brands).
The model's real output isn't boxes β it's a probability map: one number per pixel for "how likely is this text?". Brighter = more confident. All the boxes above are decoded from this map: threshold it, group connected bright pixels into regions, then fit a minimum-area (possibly rotated) rectangle to each. That's the whole DB decode, made visible.
Detection is the first stage of every OCR and document pipeline β and doing it on-device means a sensitive document (a receipt, an ID, a form) never has to be uploaded to find its text. Once you know where text is, you can act on regions without reading a word:
This detector locates text regions; it does not recognise characters, languages, or reading order β pair it with an OCR model for that.
One image in, oriented boxes out β see the model find every text region and count them.
On-device redaction β detect every text region in a document and black it out before sharing.
Rotated, angled, dense text β watch the oriented boxes tilt to hug slanted poster type.
Detect β read: locate each text region, then run TrOCR on the crops to actually read them.
transformers.js has no DBNet text-detection class, so we run the ONNX graph directly with ONNX Runtime Web. The model gives a probability map; the "DB decode" turns it into boxes:
import * as ort from "onnxruntime-web";
const session = await ort.InferenceSession.create(dbnetBytes, { executionProviders: ["wasm"] });
// image β [1,3,H,W] NCHW (H,W multiples of 32), ImageNet-normalised
const input = new ort.Tensor("float32", normalize(image), [1, 3, H, W]);
const { [session.outputNames[0]]: prob } = await session.run({ [session.inputNames[0]]: input });
// DB decode: threshold the probability map β connected components β min-area box per region
const regions = decode(prob.data, W, H, /*thresh*/ 0.3, /*boxThresh*/ 0.5);
Inference and the whole decode run in a Web Worker so the UI never blocks, and the 2.4 MB model is fetched through Cache Storage, so a returning visit auto-initialises with no re-download.