Skip to main content
Version: 0.10.0

Function: createSemanticSegmenter()

createSemanticSegmenter<L>(config, runtime?): Promise<SemanticSegmenter<L>>

Defined in: extensions/cv/tasks/semanticSegmentation.ts:149

Creates a semantic segmenter runner for executing local Semantic Segmentation models.

It validates the model inputs and outputs, asserts that the labels array length matches the model's output vocabulary size, pre-allocates the necessary static execution tensors, sets up an image preprocessor, and registers clean disposal hooks to clear all native memory.

Type Parameters

L

L extends PropertyKey = string

The type representing the segmentation labels.

Parameters

config

SemanticSegmenterModel<L>

Segmenter task configuration containing path and options. See SemanticSegmenterModel.

runtime?

any

Optional worklet runtime thread environment context.

Returns

Promise<SemanticSegmenter<L>>

A promise resolving to the instantiated SemanticSegmenter runner.

Throws

With code LOAD_FAILED if model fails to load, SCHEMA_MISMATCH if model schema does not match segmentation spec, or INVALID_ARGUMENT if labels length does not match model output classes.