Skip to content

Latest commit

 

History

History
82 lines (44 loc) · 2.23 KB

File metadata and controls

82 lines (44 loc) · 2.23 KB

Function: useInstanceSegmenter()

useInstanceSegmenter<F, L>(config, options?): object

Defined in: hooks/useInstanceSegmenter.ts:28

React hook to load and run an instance 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 createInstanceSegmenter.

Type Parameters

F

F extends "xyxy" | "xywh" | "cxcywh"

The bounding box format.

L

L

The class labels type.

Parameters

config

InstanceSegmenterModel<F, L>

The instance segmentation model configuration. See InstanceSegmenterModel.

options?

ResourceOptions

Load and caching options. See ResourceOptions.

Returns

object

The same object as InstanceSegmenter (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: InstanceSegmenterModel<F, L> | undefined

segmentInstances

segmentInstances: (input, options?) => Promise<InstanceSegmentationResult<F, L>[]> | undefined = model.segmentInstances

segmentInstancesWorklet

segmentInstancesWorklet: (input, options?) => InstanceSegmentationResult<F, L>[] | undefined = model.segmentInstancesWorklet

See

InstanceSegmenter