Skip to content

Latest commit

 

History

History
50 lines (32 loc) · 1.87 KB

File metadata and controls

50 lines (32 loc) · 1.87 KB

Function: useInstanceSegmentation()

useInstanceSegmentation<C>(props): InstanceSegmentationType<InstanceSegmentationLabels<C["modelName"]>>

Defined in: hooks/computer_vision/useInstanceSegmentation.ts:38

React hook for managing an Instance Segmentation model instance.

Type Parameters

C

C extends InstanceSegmentationModelSources

A InstanceSegmentationModelSources config specifying which model to load.

Parameters

props

InstanceSegmentationProps<C>

Configuration object containing model config and optional preventLoad flag.

Returns

InstanceSegmentationType<InstanceSegmentationLabels<C["modelName"]>>

An object with model state (error, isReady, isGenerating, downloadProgress), a typed forward function, getAvailableInputSizes helper, and a runOnFrame worklet for VisionCamera integration.

Example

const { isReady, isGenerating, forward, error, downloadProgress, getAvailableInputSizes, runOnFrame } =
  useInstanceSegmentation({
    model: {
      modelName: 'yolo26n-seg',
      modelSource: 'https://huggingface.co/.../yolo26n-seg.pte',
    },
  });

if (!isReady) {
  return <Text>Loading: {(downloadProgress * 100).toFixed(0)}%</Text>;
}

const results = await forward('path/to/image.jpg', {
  confidenceThreshold: 0.5,
  inputSize: 640,
});