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: number

error​

error: Error | undefined

isReady​

isReady: boolean = !!model

labels​

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

resource​

resource: SemanticSegmenterModel<L> | undefined

segment​

segment: (input, colormap?) => Promise<SemanticSegmentationResult<L>> | undefined = model.segment

segmentWorklet​

segmentWorklet: (input, colormap?) => SemanticSegmentationResult<L> | undefined = model.segmentWorklet

See​

SemanticSegmenter