Skip to main content
Segmentation outlines objects in an image and labels them. Where a vision model describes a picture in words, segmentation gives you the regions themselves: a mask per object, with a class and a confidence.

Building the input

Passing a path rather than bytes avoids reading a large image into JavaScript memory only to hand it back to native code.

Options

Turn the diagnostic image on while you are building the feature: it shows you what the model actually found, which is much faster than reasoning about mask arrays. Turn it off in production, since rendering it costs time and memory.

What comes back

A SegmentationResult holds the regions found. Each carries its class label, a confidence, and the mask itself, so you can draw an outline, crop to the object, or count instances.

Segmentation or a vision model

Availability

Segmentation runs on the ONNX backend, which does not load on win32-arm64. Check capabilities() before offering it.