Skip to main content
Version: 0.10.0

Function: useSemanticSegmenter()

useSemanticSegmenter<L>(config, options?): object

Defined in: hooks/useSemanticSegmenter.ts:26

React hook to load and run a semantic segmentation model.

This hook manages downloading (if remote URLs are provided) and loading the model assets, compiling them, tracking download progress and load errors, and releasing native memory when the component unmounts or the configuration changes.

For imperative usage, see createSemanticSegmenter.

Type Parameters

L

L extends PropertyKey = string

The type representing the segmentation labels.

Parameters

config

SemanticSegmenterModel<L>

The semantic segmentation model configuration. See SemanticSegmenterModel.

options?

ResourceOptions

Load and caching options. See ResourceOptions.

Returns

object

The same object as SemanticSegmenter (without dispose), combined with loading state, download progress, and labels.

downloadProgress

downloadProgress: any

error

error: any

isReady

isReady: boolean = !!model

labels

labels: readonly L[] = config.modelOpts.labels

resource

resource: any

segment

segment: any = model.segment

segmentWorklet

segmentWorklet: any = model.segmentWorklet

See

SemanticSegmenter