Salient-object foreground segmentation on an Image with U2-Net. The single most prominent subject is isolated and the sink resolves the arm: (Segmentation, BoundingBox), (Mask, DetectedClass), a [Mask], or a colourised foreground Image.
Typical backends
Isolate the salient subject and crop to its bounding box.
Visualise the foreground matte from a live stream.
Caveats
- I/O contractThe output arm is a single downstream-resolved choice fixed at deploy time; every arm describes the same single foreground region with class id zero, so the mask, box and confidence stay consistent across arms.
- LimitationOnly one salient subject is segmented per frame; use a class- or prompt-driven segmenter when several distinct objects must be separated.
- Parameter interaction
threshold cuts the normalised saliency map into the binary mask; raise it to keep only the confident core and lower it to include soft edges.
- FallbackWhen nothing clears the cutoff the output still carries an all-false mask and a zero-area box, so frames are never dropped.
- AccuracySaliency is computed at a fixed small input size and resampled back to the source resolution, so very thin or hairline structures can be lost.
- State lifetimeThe bound ONNX checkpoint,
device and threshold are captured once at startup; the `u2net.onnx` slot file is staged locally and loaded offline, so nothing is fetched from a remote at deploy or runtime.