diff --git a/apps/computer-vision/app/_layout.tsx b/apps/computer-vision/app/_layout.tsx index 8b66a796c..a0571911c 100644 --- a/apps/computer-vision/app/_layout.tsx +++ b/apps/computer-vision/app/_layout.tsx @@ -75,6 +75,14 @@ export default function _layout() { headerTitleStyle: { color: ColorPalette.primary }, }} /> + Object Detection + router.navigate('instance_segmentation/')} + > + Instance Segmentation + router.navigate('ocr/')} diff --git a/apps/computer-vision/app/instance_segmentation/index.tsx b/apps/computer-vision/app/instance_segmentation/index.tsx new file mode 100644 index 000000000..268422c54 --- /dev/null +++ b/apps/computer-vision/app/instance_segmentation/index.tsx @@ -0,0 +1,304 @@ +import Spinner from '../../components/Spinner'; +import { BottomBar } from '../../components/BottomBar'; +import ImageWithInstanceMasks from '../../components/ImageWithInstanceMasks'; +import { getImage } from '../../utils'; +import { + useInstanceSegmentation, + YOLO26N_SEG, + YOLO_SEG_CONFIG, + // InstanceSegmentationModule, // Uncomment for custom models + // CocoLabel, // Uncomment for custom models +} from 'react-native-executorch'; +import { + View, + StyleSheet, + ScrollView, + Text, + TouchableOpacity, +} from 'react-native'; +import React, { useContext, useEffect, useState } from 'react'; +import { GeneratingContext } from '../../context'; +import ScreenWrapper from '../../ScreenWrapper'; + +export default function InstanceSegmentationScreen() { + const { setGlobalGenerating } = useContext(GeneratingContext); + + // Using YOLO hook + const { isReady, isGenerating, downloadProgress, error, forward } = + useInstanceSegmentation({ + model: YOLO26N_SEG, // YOLO26N_SEG already contains modelName and modelSource + }); + + const [imageUri, setImageUri] = useState(''); + const [imageSize, setImageSize] = useState({ width: 0, height: 0 }); + const [instances, setInstances] = useState([]); + const [selectedInputSize, setSelectedInputSize] = useState(640); + + // RFDetr custom model (commented out - use this for custom models) + /* + const [isReady, setIsReady] = useState(false); + const [isGenerating, setIsGenerating] = useState(false); + const [downloadProgress, setDownloadProgress] = useState(0); + const [error, setError] = useState(null); + const [modelInstance, setModelInstance] = useState | null>(null); + + useEffect(() => { + let isMounted = true; + let instance: InstanceSegmentationModule | null = null; + + (async () => { + try { + setIsReady(false); + setError(null); + + instance = await InstanceSegmentationModule.fromCustomConfig( + 'http://192.168.0.201:3000/rfdetr_seg.pte', + { + labelMap: CocoLabel, + postprocessorConfig: { + type: 'rfdetr', + defaultConfidenceThreshold: 0.5, + defaultIouThreshold: 0.5, + applyNMS: true, // RFDetr needs NMS + }, + }, + (progress) => { + if (isMounted) setDownloadProgress(progress); + } + ); + + if (isMounted) { + setModelInstance(instance); + setIsReady(true); + } + } catch (err) { + if (isMounted) setError(err); + } + })(); + + return () => { + isMounted = false; + instance?.delete(); + }; + }, []); + */ + + useEffect(() => { + setGlobalGenerating(isGenerating); + }, [isGenerating, setGlobalGenerating]); + + const handleCameraPress = async (isCamera: boolean) => { + const image = await getImage(isCamera); + if (!image?.uri) return; + setImageUri(image.uri); + setImageSize({ + width: image.width ?? 0, + height: image.height ?? 0, + }); + setInstances([]); + }; + + const runForward = async () => { + if (!imageUri || imageSize.width === 0 || imageSize.height === 0) return; + + try { + const output = await forward(imageUri, { + confidenceThreshold: 0.2, + iouThreshold: 0.45, + maxInstances: 20, + inputSize: selectedInputSize, // YOLO supports multiple input sizes + }); + + setInstances(output); + } catch (e) { + console.error(e); + } + }; + + if (!isReady && error) { + return ( + + + Error Loading Model + + {error?.message || 'Unknown error occurred'} + + Code: {error?.code || 'N/A'} + + + ); + } + + if (!isReady) { + return ( + + ); + } + + return ( + + + {/* Image with Instance Masks */} + + + + + {imageUri && ( + + Input Size: + + {YOLO_SEG_CONFIG.availableInputSizes!.map((size) => ( + setSelectedInputSize(size)} + > + + {size} + + + ))} + + + )} + + {instances.length > 0 && ( + + + Detected {instances.length} instance(s) + + + {instances.map((instance, idx) => ( + + + {instance.label || 'Unknown'} ( + {(instance.score * 100).toFixed(1)}%) + + + ))} + + + )} + + + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 6, + }, + imageCanvasContainer: { + flex: 1, + padding: 16, + }, + inputSizeContainer: { + paddingHorizontal: 16, + paddingVertical: 12, + backgroundColor: '#fff', + borderTopWidth: 1, + borderTopColor: '#e0e0e0', + }, + inputSizeLabel: { + fontSize: 14, + fontWeight: '600', + color: '#333', + marginBottom: 8, + }, + sizeButton: { + paddingHorizontal: 16, + paddingVertical: 8, + marginRight: 8, + borderRadius: 6, + backgroundColor: '#f0f0f0', + }, + sizeButtonActive: { + backgroundColor: '#007AFF', + }, + sizeButtonText: { + fontSize: 14, + fontWeight: '600', + color: '#666', + }, + sizeButtonTextActive: { + color: '#fff', + }, + resultsContainer: { + maxHeight: 200, + paddingHorizontal: 16, + paddingVertical: 12, + backgroundColor: '#fff', + borderTopWidth: 1, + borderTopColor: '#e0e0e0', + }, + resultsHeader: { + fontSize: 16, + fontWeight: '600', + marginBottom: 8, + color: '#333', + }, + resultsList: { + flex: 1, + }, + resultRow: { + flexDirection: 'row', + alignItems: 'center', + paddingVertical: 6, + paddingHorizontal: 8, + marginBottom: 4, + backgroundColor: '#f9f9f9', + borderRadius: 6, + }, + resultText: { + fontSize: 14, + fontWeight: '500', + color: '#333', + }, + errorContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + padding: 32, + }, + errorTitle: { + fontSize: 20, + fontWeight: '700', + color: '#e74c3c', + marginBottom: 12, + }, + errorText: { + fontSize: 14, + color: '#555', + textAlign: 'center', + marginBottom: 8, + }, + errorCode: { + fontSize: 12, + color: '#999', + fontFamily: 'Courier', + }, +}); diff --git a/apps/computer-vision/components/ImageWithInstanceMasks.tsx b/apps/computer-vision/components/ImageWithInstanceMasks.tsx new file mode 100644 index 000000000..e3074d936 --- /dev/null +++ b/apps/computer-vision/components/ImageWithInstanceMasks.tsx @@ -0,0 +1,258 @@ +import React, { useState, useEffect } from 'react'; +import { Image, StyleSheet, View, Text } from 'react-native'; +import { + Canvas, + Image as SkiaImage, + Skia, + AlphaType, + ColorType, + SkImage, + Rect, + Group, +} from '@shopify/react-native-skia'; + +// Color palette for different instances +const DEFAULT_COLORS = [ + [255, 87, 51, 180], // Red + [51, 255, 87, 180], // Green + [51, 87, 255, 180], // Blue + [255, 51, 246, 180], // Magenta + [51, 255, 246, 180], // Cyan + [243, 255, 51, 180], // Yellow + [141, 51, 255, 180], // Purple + [255, 131, 51, 180], // Orange + [51, 255, 131, 180], // Spring Green + [131, 51, 255, 180], // Violet +]; + +interface SegmentedInstance { + bbox: { + x1: number; + y1: number; + x2: number; + y2: number; + }; + mask?: Uint8Array; + maskWidth?: number; + maskHeight?: number; + label: string; + score: number; + instanceId: number; +} + +interface Props { + imageUri: string; + instances: SegmentedInstance[]; + imageWidth: number; + imageHeight: number; + showMasks?: boolean; + colors?: number[][]; +} + +export default function ImageWithInstanceMasks({ + imageUri, + instances, + imageWidth, + imageHeight, + showMasks = true, + colors = DEFAULT_COLORS, +}: Props) { + const [canvasSize, setCanvasSize] = useState({ width: 0, height: 0 }); + const [maskImages, setMaskImages] = useState([]); + + // Generate Skia mask images when instances change + useEffect(() => { + if (!showMasks || !instances.length) { + setMaskImages([]); + return; + } + + const images: SkImage[] = []; + for (let i = 0; i < instances.length; i++) { + const instance = instances[i]; + if (!instance.mask || !instance.maskWidth || !instance.maskHeight) { + continue; + } + + const color = colors[i % colors.length]; + const pixels = new Uint8Array( + instance.maskWidth * instance.maskHeight * 4 + ); + + for (let j = 0; j < instance.mask.length; j++) { + if (instance.mask[j] > 0) { + pixels[j * 4] = color[0]; + pixels[j * 4 + 1] = color[1]; + pixels[j * 4 + 2] = color[2]; + pixels[j * 4 + 3] = color[3]; + } else { + pixels[j * 4 + 3] = 0; + } + } + + const data = Skia.Data.fromBytes(pixels); + const img = Skia.Image.MakeImage( + { + width: instance.maskWidth, + height: instance.maskHeight, + alphaType: AlphaType.Premul, + colorType: ColorType.RGBA_8888, + }, + data, + instance.maskWidth * 4 + ); + + if (img) { + images.push(img); + } + } + + setMaskImages(images); + }, [instances, showMasks, colors]); + + const calculateScale = () => { + const scaleX = canvasSize.width / (imageWidth || 1); + const scaleY = canvasSize.height / (imageHeight || 1); + const scale = Math.min(scaleX, scaleY); + const offsetX = (canvasSize.width - imageWidth * scale) / 2; + const offsetY = (canvasSize.height - imageHeight * scale) / 2; + return { scale, offsetX, offsetY }; + }; + + const { scale, offsetX, offsetY } = calculateScale(); + + return ( + + {/* Base Image */} + + + + + {/* Masks and Bounding Boxes */} + {instances.length > 0 && ( + + setCanvasSize({ + width: e.nativeEvent.layout.width, + height: e.nativeEvent.layout.height, + }) + } + > + + {/* Render masks */} + {showMasks && + maskImages.map((maskImg, idx) => ( + + ))} + + {/* Render bounding boxes */} + {instances.map((instance, idx) => { + const color = colors[idx % colors.length]; + const bboxX = instance.bbox.x1 * scale + offsetX; + const bboxY = instance.bbox.y1 * scale + offsetY; + const bboxWidth = (instance.bbox.x2 - instance.bbox.x1) * scale; + const bboxHeight = (instance.bbox.y2 - instance.bbox.y1) * scale; + + return ( + + + + ); + })} + + + {/* Render labels using React Native Text */} + {instances.map((instance, idx) => { + const color = colors[idx % colors.length]; + const bboxX = instance.bbox.x1 * scale + offsetX; + const bboxY = instance.bbox.y1 * scale + offsetY; + const labelText = `${instance.label || 'Unknown'} ${(instance.score * 100).toFixed(0)}%`; + + return ( + + {labelText} + + ); + })} + + )} + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + width: '100%', + }, + imageContainer: { + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, + borderRadius: 8, + overflow: 'hidden', + }, + image: { + width: '100%', + height: '100%', + }, + canvasContainer: { + flex: 1, + justifyContent: 'center', + alignItems: 'center', + borderRadius: 8, + overflow: 'hidden', + }, + canvas: { + width: '100%', + height: '100%', + }, + labelContainer: { + position: 'absolute', + paddingHorizontal: 6, + paddingVertical: 2, + borderRadius: 4, + }, + labelText: { + color: 'white', + fontSize: 12, + fontWeight: '600', + }, +}); diff --git a/apps/computer-vision/package.json b/apps/computer-vision/package.json index ec5894498..c63c26e07 100644 --- a/apps/computer-vision/package.json +++ b/apps/computer-vision/package.json @@ -12,6 +12,7 @@ }, "dependencies": { "@react-native-executorch/expo-resource-fetcher": "workspace:*", + "@react-native-picker/picker": "^2.11.4", "@react-native/metro-config": "^0.81.5", "@react-navigation/drawer": "^7.8.1", "@react-navigation/native": "^7.1.28", diff --git a/docs/docs/02-benchmarks/inference-time.md b/docs/docs/02-benchmarks/inference-time.md index a1580169a..1b2c60f84 100644 --- a/docs/docs/02-benchmarks/inference-time.md +++ b/docs/docs/02-benchmarks/inference-time.md @@ -127,6 +127,23 @@ Times presented in the tables are measured as consecutive runs of the model. Ini | ----------------- | ---------------------------- | -------------------------------- | --------------------------------- | | DEELABV3_RESNET50 | 1000 | 670 | 700 | +## Instance Segmentation + +:::warning +Times presented in the tables are measured as consecutive runs of the model. Initial run times may be up to 2x longer due to model loading and initialization. +::: +:::warning +Times presented in the tables are measured for forward method with input size equal to 512. Other input sizes may yeild slower or faster inference times. +::: + +| Model | Samsung Galaxy S24 (XNNPACK) [ms] | Iphone 17 pro (XNNPACK) [ms] | +| ----------- | --------------------------------- | ---------------------------- | +| YOLO26n_SEG | 92 | 90 | +| YOLO26s_SEG | 220 | 188 | +| YOLO26m_SEG | 570 | 550 | +| YOLO26l_SEG | 680 | 608 | +| YOLO26x_SEG | 1410 | 1338 | + ## Text to image | Model | iPhone 17 Pro (XNNPACK) [ms] | iPhone 16 Pro (XNNPACK) [ms] | iPhone SE 3 (XNNPACK) [ms] | Samsung Galaxy S24 (XNNPACK) [ms] | OnePlus 12 (XNNPACK) [ms] | diff --git a/docs/docs/02-benchmarks/memory-usage.md b/docs/docs/02-benchmarks/memory-usage.md index 2f921cb48..a12112301 100644 --- a/docs/docs/02-benchmarks/memory-usage.md +++ b/docs/docs/02-benchmarks/memory-usage.md @@ -93,6 +93,20 @@ Data presented in the following sections is based on inference with non-resized | ----------------- | ---------------------- | ------------------ | | DEELABV3_RESNET50 | 930 | 660 | +## Instance Segmentation + +:::warning +Data presented in the following sections is based on inference with forward_1024 method. +::: + +| Model | Android (XNNPACK) [MB] | iOS (XNNPACK) [MB] | +| ----------- | ---------------------- | ------------------ | +| YOLO26n_SEG | 680 | 670 | +| YOLO26s_SEG | 725 | 715 | +| YOLO26m_SEG | 820 | 815 | +| YOLO26l_SEG | 1040 | 1025 | +| YOLO26x_SEG | 1410 | 1450 | + ## Text to image | Model | Android (XNNPACK) [MB] | iOS (XNNPACK) [MB] | diff --git a/docs/docs/02-benchmarks/model-size.md b/docs/docs/02-benchmarks/model-size.md index 7fa1d7f38..852bfc3d1 100644 --- a/docs/docs/02-benchmarks/model-size.md +++ b/docs/docs/02-benchmarks/model-size.md @@ -92,6 +92,16 @@ title: Model Size | ----------------- | ------------ | | DEELABV3_RESNET50 | 168 | +## Instance Segmentation + +| Model | XNNPACK [MB] | +| ----------- | ------------ | +| YOLO26N_SEG | 13.6 | +| YOLO26S_SEG | 46.2 | +| YOLO26M_SEG | 105 | +| YOLO26L_SEG | 123 | +| YOLO26X_SEG | 274 | + ## Text to image | Model | Text encoder (XNNPACK) [MB] | UNet (XNNPACK) [MB] | VAE decoder (XNNPACK) [MB] | diff --git a/docs/docs/03-hooks/02-computer-vision/useSemanticSegmentation.md b/docs/docs/03-hooks/02-computer-vision/useSemanticSegmentation.md index 3a6fa4655..bd799974d 100644 --- a/docs/docs/03-hooks/02-computer-vision/useSemanticSegmentation.md +++ b/docs/docs/03-hooks/02-computer-vision/useSemanticSegmentation.md @@ -5,13 +5,13 @@ title: useSemanticSegmentation Semantic semantic segmentation, akin to image classification, tries to assign the content of the image to one of the predefined classes. However, in case of segmentation this classification is done on a per-pixel basis, so as the result the model provides an image-sized array of scores for each of the classes. You can then use this information to detect objects on a per-pixel basis. React Native ExecuTorch offers a dedicated hook `useSemanticSegmentation` for this task. :::warning -It is recommended to use models provided by us which are available at our [Hugging Face repository](https://huggingface.co/collections/software-mansion/semantic-segmentation-68d5291bdf4a30bee0220f4f), you can also use [constants](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/constants/modelUrls.ts) shipped with our library. +It is recommended to use models provided by us which are available at our [Hugging Face repository](https://huggingface.co/collections/software-mansion/image-segmentation-68d5291bdf4a30bee0220f4f), you can also use [constants](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/constants/modelUrls.ts) shipped with our library. ::: ## API Reference - For detailed API Reference for `useSemanticSegmentation` see: [`useSemanticSegmentation` API Reference](../../06-api-reference/functions/useSemanticSegmentation.md). -- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---semantic-segmentation). +- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---image-segmentation). ## High Level Overview @@ -49,7 +49,7 @@ The hook is generic over the model config — TypeScript automatically infers th You need more details? Check the following resources: - For detailed information about `useSemanticSegmentation` arguments check this section: [`useSemanticSegmentation` arguments](../../06-api-reference/functions/useSemanticSegmentation.md#parameters). -- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---semantic-segmentation). +- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---image-segmentation). - For more information on loading resources, take a look at [loading models](../../01-fundamentals/02-loading-models.md) page. ### Returns @@ -117,12 +117,7 @@ function App() { ## Supported models -| Model | Number of classes | Class list | Quantized | -| ----------------------------------------------------------------------------------------------------------- | ----------------- | ----------------------------------------------------------------------------------------- | :-------: | -| [deeplab-v3-resnet50](https://huggingface.co/software-mansion/react-native-executorch-deeplab-v3) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [deeplab-v3-resnet101](https://huggingface.co/software-mansion/react-native-executorch-deeplab-v3) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [deeplab-v3-mobilenet-v3-large](https://huggingface.co/software-mansion/react-native-executorch-deeplab-v3) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [lraspp-mobilenet-v3-large](https://huggingface.co/software-mansion/react-native-executorch-lraspp) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [fcn-resnet50](https://huggingface.co/software-mansion/react-native-executorch-fcn) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [fcn-resnet101](https://huggingface.co/software-mansion/react-native-executorch-fcn) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | Yes | -| [selfie-segmentation](https://huggingface.co/software-mansion/react-native-executorch-selfie-segmentation) | 2 | [SelfieSegmentationLabel](../../06-api-reference/enumerations/SelfieSegmentationLabel.md) | No | +| Model | Number of classes | Class list | +| ------------------------------------------------------------------------------------------------ | ----------------- | ----------------------------------------------------------------------------------------- | +| [deeplabv3_resnet50](https://huggingface.co/software-mansion/react-native-executorch-deeplab-v3) | 21 | [DeeplabLabel](../../06-api-reference/enumerations/DeeplabLabel.md) | +| selfie-segmentation | 2 | [SelfieSegmentationLabel](../../06-api-reference/enumerations/SelfieSegmentationLabel.md) | diff --git a/docs/docs/04-typescript-api/02-computer-vision/SemanticSegmentationModule.md b/docs/docs/04-typescript-api/02-computer-vision/SemanticSegmentationModule.md index 7ba0182ee..63c05628b 100644 --- a/docs/docs/04-typescript-api/02-computer-vision/SemanticSegmentationModule.md +++ b/docs/docs/04-typescript-api/02-computer-vision/SemanticSegmentationModule.md @@ -7,7 +7,7 @@ TypeScript API implementation of the [useSemanticSegmentation](../../03-hooks/02 ## API Reference - For detailed API Reference for `SemanticSegmentationModule` see: [`SemanticSegmentationModule` API Reference](../../06-api-reference/classes/SemanticSegmentationModule.md). -- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---semantic-segmentation). +- For all semantic segmentation models available out-of-the-box in React Native ExecuTorch see: [Semantic Segmentation Models](../../06-api-reference/index.md#models---image-segmentation). ## High Level Overview @@ -49,7 +49,7 @@ const segmentation = await SemanticSegmentationModule.fromModelName( ); ``` -The `config` parameter is a discriminated union — TypeScript ensures you provide the correct fields for each model name. Available built-in models: `'deeplab-v3-resnet50'`, `'deeplab-v3-resnet50-quantized'`, `'deeplab-v3-resnet101'`, `'deeplab-v3-resnet101-quantized'`, `'deeplab-v3-mobilenet-v3-large'`, `'deeplab-v3-mobilenet-v3-large-quantized'`, `'lraspp-mobilenet-v3-large'`, `'lraspp-mobilenet-v3-large-quantized'`, `'fcn-resnet50'`, `'fcn-resnet50-quantized'`, `'fcn-resnet101'`, `'fcn-resnet101-quantized'`, and `'selfie-segmentation'`. +The `config` parameter is a discriminated union — TypeScript ensures you provide the correct fields for each model name. Available built-in models: `'deeplab-v3'`, `'selfie-segmentation'`. ### Custom models — `fromCustomConfig` diff --git a/docs/docs/06-api-reference/classes/SemanticSegmentationModule.md b/docs/docs/06-api-reference/classes/SemanticSegmentationModule.md index 861d86e08..5465d3248 100644 --- a/docs/docs/06-api-reference/classes/SemanticSegmentationModule.md +++ b/docs/docs/06-api-reference/classes/SemanticSegmentationModule.md @@ -1,9 +1,9 @@ # Class: SemanticSegmentationModule\ -Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:81](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L81) +Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L60) Generic semantic segmentation module with type-safe label maps. -Use a model name (e.g. `'deeplab-v3-resnet50'`) as the generic parameter for built-in models, +Use a model name (e.g. `'deeplab-v3'`) as the generic parameter for built-in models, or a custom label enum for custom configs. ## Extends @@ -185,9 +185,9 @@ Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:97](https://g ### fromCustomConfig() -> `static` **fromCustomConfig**\<`L`\>(`modelSource`, `config`, `onDownloadProgress?`): `Promise`\<`SemanticSegmentationModule`\<`L`\>\> +> `static` **fromCustomConfig**\<`L`\>(`modelSource`, `config`, `onDownloadProgress`): `Promise`\<`SemanticSegmentationModule`\<`L`\>\> -Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:163](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L163) +Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:142](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L142) Creates a segmentation instance with a user-provided label map and custom config. Use this when working with a custom-exported segmentation model that is not one of the built-in models. @@ -238,22 +238,6 @@ const segmentation = await SemanticSegmentationModule.fromCustomConfig( ### fromModelName() -> `static` **fromModelName**\<`C`\>(`config`, `onDownloadProgress?`): `Promise`\<`SemanticSegmentationModule`\<[`ModelNameOf`](../type-aliases/ModelNameOf.md)\<`C`\>\>\> - -Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:116](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L116) - -Creates a segmentation instance for a built-in model. -The config object is discriminated by `modelName` — each model can require different fields. - -#### Type Parameters - -##### C - -`C` _extends_ [`SemanticSegmentationModelSources`](../type-aliases/SemanticSegmentationModelSources.md) - -#### Parameters - -##### config `C` diff --git a/docs/docs/06-api-reference/enumerations/DeeplabLabel.md b/docs/docs/06-api-reference/enumerations/DeeplabLabel.md index 7fc8ec2c2..b23c7ce9c 100644 --- a/docs/docs/06-api-reference/enumerations/DeeplabLabel.md +++ b/docs/docs/06-api-reference/enumerations/DeeplabLabel.md @@ -1,8 +1,8 @@ # Enumeration: DeeplabLabel -Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) +Defined in: [types/semanticSegmentation.ts:53](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L53) -Labels used in the DeepLab semantic segmentation model. +Labels used in the DeepLab image segmentation model. ## Enumeration Members @@ -10,7 +10,7 @@ Labels used in the DeepLab semantic segmentation model. > **AEROPLANE**: `1` -Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) +Defined in: [types/semanticSegmentation.ts:55](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L55) --- @@ -18,7 +18,7 @@ Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansi > **BACKGROUND**: `0` -Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) +Defined in: [types/semanticSegmentation.ts:54](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L54) --- @@ -26,7 +26,7 @@ Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansi > **BICYCLE**: `2` -Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) +Defined in: [types/semanticSegmentation.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L56) --- @@ -34,7 +34,7 @@ Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansi > **BIRD**: `3` -Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) +Defined in: [types/semanticSegmentation.ts:57](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L57) --- @@ -42,7 +42,7 @@ Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansi > **BOAT**: `4` -Defined in: [types/semanticSegmentation.ts:75](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L75) +Defined in: [types/semanticSegmentation.ts:58](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L58) --- @@ -50,7 +50,7 @@ Defined in: [types/semanticSegmentation.ts:75](https://github.com/software-mansi > **BOTTLE**: `5` -Defined in: [types/semanticSegmentation.ts:76](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L76) +Defined in: [types/semanticSegmentation.ts:59](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L59) --- @@ -58,7 +58,7 @@ Defined in: [types/semanticSegmentation.ts:76](https://github.com/software-mansi > **BUS**: `6` -Defined in: [types/semanticSegmentation.ts:77](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L77) +Defined in: [types/semanticSegmentation.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L60) --- @@ -66,7 +66,7 @@ Defined in: [types/semanticSegmentation.ts:77](https://github.com/software-mansi > **CAR**: `7` -Defined in: [types/semanticSegmentation.ts:78](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L78) +Defined in: [types/semanticSegmentation.ts:61](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L61) --- @@ -74,7 +74,7 @@ Defined in: [types/semanticSegmentation.ts:78](https://github.com/software-mansi > **CAT**: `8` -Defined in: [types/semanticSegmentation.ts:79](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L79) +Defined in: [types/semanticSegmentation.ts:62](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L62) --- @@ -82,7 +82,7 @@ Defined in: [types/semanticSegmentation.ts:79](https://github.com/software-mansi > **CHAIR**: `9` -Defined in: [types/semanticSegmentation.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L80) +Defined in: [types/semanticSegmentation.ts:63](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L63) --- @@ -90,7 +90,7 @@ Defined in: [types/semanticSegmentation.ts:80](https://github.com/software-mansi > **COW**: `10` -Defined in: [types/semanticSegmentation.ts:81](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L81) +Defined in: [types/semanticSegmentation.ts:64](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L64) --- @@ -98,7 +98,7 @@ Defined in: [types/semanticSegmentation.ts:81](https://github.com/software-mansi > **DININGTABLE**: `11` -Defined in: [types/semanticSegmentation.ts:82](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L82) +Defined in: [types/semanticSegmentation.ts:65](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L65) --- @@ -106,7 +106,7 @@ Defined in: [types/semanticSegmentation.ts:82](https://github.com/software-mansi > **DOG**: `12` -Defined in: [types/semanticSegmentation.ts:83](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L83) +Defined in: [types/semanticSegmentation.ts:66](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L66) --- @@ -114,7 +114,7 @@ Defined in: [types/semanticSegmentation.ts:83](https://github.com/software-mansi > **HORSE**: `13` -Defined in: [types/semanticSegmentation.ts:84](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L84) +Defined in: [types/semanticSegmentation.ts:67](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L67) --- @@ -122,7 +122,7 @@ Defined in: [types/semanticSegmentation.ts:84](https://github.com/software-mansi > **MOTORBIKE**: `14` -Defined in: [types/semanticSegmentation.ts:85](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L85) +Defined in: [types/semanticSegmentation.ts:68](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L68) --- @@ -130,7 +130,7 @@ Defined in: [types/semanticSegmentation.ts:85](https://github.com/software-mansi > **PERSON**: `15` -Defined in: [types/semanticSegmentation.ts:86](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L86) +Defined in: [types/semanticSegmentation.ts:69](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L69) --- @@ -138,7 +138,7 @@ Defined in: [types/semanticSegmentation.ts:86](https://github.com/software-mansi > **POTTEDPLANT**: `16` -Defined in: [types/semanticSegmentation.ts:87](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L87) +Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) --- @@ -146,7 +146,7 @@ Defined in: [types/semanticSegmentation.ts:87](https://github.com/software-mansi > **SHEEP**: `17` -Defined in: [types/semanticSegmentation.ts:88](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L88) +Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) --- @@ -154,7 +154,7 @@ Defined in: [types/semanticSegmentation.ts:88](https://github.com/software-mansi > **SOFA**: `18` -Defined in: [types/semanticSegmentation.ts:89](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L89) +Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) --- @@ -162,7 +162,7 @@ Defined in: [types/semanticSegmentation.ts:89](https://github.com/software-mansi > **TRAIN**: `19` -Defined in: [types/semanticSegmentation.ts:90](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L90) +Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) --- @@ -170,4 +170,4 @@ Defined in: [types/semanticSegmentation.ts:90](https://github.com/software-mansi > **TVMONITOR**: `20` -Defined in: [types/semanticSegmentation.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L91) +Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) diff --git a/docs/docs/06-api-reference/enumerations/DeeplabLabel_BACKUP_24210.md b/docs/docs/06-api-reference/enumerations/DeeplabLabel_BACKUP_24210.md new file mode 100644 index 000000000..c8cd20d77 --- /dev/null +++ b/docs/docs/06-api-reference/enumerations/DeeplabLabel_BACKUP_24210.md @@ -0,0 +1,261 @@ +# Enumeration: DeeplabLabel + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) +======= +Defined in: [types/semanticSegmentation.ts:53](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L53) +>>>>>>> 0fe4c930f (chore: Update docs) + +Labels used in the DeepLab semantic segmentation model. + +## Enumeration Members + +### AEROPLANE + +> **AEROPLANE**: `1` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) +======= +Defined in: [types/semanticSegmentation.ts:55](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L55) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BACKGROUND + +> **BACKGROUND**: `0` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) +======= +Defined in: [types/semanticSegmentation.ts:54](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L54) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BICYCLE + +> **BICYCLE**: `2` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) +======= +Defined in: [types/semanticSegmentation.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L56) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BIRD + +> **BIRD**: `3` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) +======= +Defined in: [types/semanticSegmentation.ts:57](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L57) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BOAT + +> **BOAT**: `4` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:75](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L75) +======= +Defined in: [types/semanticSegmentation.ts:58](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L58) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BOTTLE + +> **BOTTLE**: `5` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:76](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L76) +======= +Defined in: [types/semanticSegmentation.ts:59](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L59) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### BUS + +> **BUS**: `6` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:77](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L77) +======= +Defined in: [types/semanticSegmentation.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L60) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### CAR + +> **CAR**: `7` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:78](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L78) +======= +Defined in: [types/semanticSegmentation.ts:61](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L61) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### CAT + +> **CAT**: `8` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:79](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L79) +======= +Defined in: [types/semanticSegmentation.ts:62](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L62) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### CHAIR + +> **CHAIR**: `9` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L80) +======= +Defined in: [types/semanticSegmentation.ts:63](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L63) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### COW + +> **COW**: `10` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:81](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L81) +======= +Defined in: [types/semanticSegmentation.ts:64](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L64) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### DININGTABLE + +> **DININGTABLE**: `11` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:82](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L82) +======= +Defined in: [types/semanticSegmentation.ts:65](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L65) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### DOG + +> **DOG**: `12` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:83](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L83) +======= +Defined in: [types/semanticSegmentation.ts:66](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L66) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### HORSE + +> **HORSE**: `13` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:84](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L84) +======= +Defined in: [types/semanticSegmentation.ts:67](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L67) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### MOTORBIKE + +> **MOTORBIKE**: `14` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:85](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L85) +======= +Defined in: [types/semanticSegmentation.ts:68](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L68) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### PERSON + +> **PERSON**: `15` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:86](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L86) +======= +Defined in: [types/semanticSegmentation.ts:69](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L69) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### POTTEDPLANT + +> **POTTEDPLANT**: `16` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:87](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L87) +======= +Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### SHEEP + +> **SHEEP**: `17` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:88](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L88) +======= +Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### SOFA + +> **SOFA**: `18` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:89](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L89) +======= +Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### TRAIN + +> **TRAIN**: `19` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:90](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L90) +======= +Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) +>>>>>>> 0fe4c930f (chore: Update docs) + +--- + +### TVMONITOR + +> **TVMONITOR**: `20` + +<<<<<<< HEAD +Defined in: [types/semanticSegmentation.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L91) +======= +Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) +>>>>>>> 0fe4c930f (chore: Update docs) diff --git a/docs/docs/06-api-reference/enumerations/DeeplabLabel_BASE_24210.md b/docs/docs/06-api-reference/enumerations/DeeplabLabel_BASE_24210.md new file mode 100644 index 000000000..4463fd1cf --- /dev/null +++ b/docs/docs/06-api-reference/enumerations/DeeplabLabel_BASE_24210.md @@ -0,0 +1,173 @@ +# Enumeration: DeeplabLabel + +Defined in: [types/imageSegmentation.ts:51](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L51) + +Labels used in the DeepLab image segmentation model. + +## Enumeration Members + +### AEROPLANE + +> **AEROPLANE**: `1` + +Defined in: [types/imageSegmentation.ts:53](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L53) + +--- + +### BACKGROUND + +> **BACKGROUND**: `0` + +Defined in: [types/imageSegmentation.ts:52](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L52) + +--- + +### BICYCLE + +> **BICYCLE**: `2` + +Defined in: [types/imageSegmentation.ts:54](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L54) + +--- + +### BIRD + +> **BIRD**: `3` + +Defined in: [types/imageSegmentation.ts:55](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L55) + +--- + +### BOAT + +> **BOAT**: `4` + +Defined in: [types/imageSegmentation.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L56) + +--- + +### BOTTLE + +> **BOTTLE**: `5` + +Defined in: [types/imageSegmentation.ts:57](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L57) + +--- + +### BUS + +> **BUS**: `6` + +Defined in: [types/imageSegmentation.ts:58](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L58) + +--- + +### CAR + +> **CAR**: `7` + +Defined in: [types/imageSegmentation.ts:59](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L59) + +--- + +### CAT + +> **CAT**: `8` + +Defined in: [types/imageSegmentation.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L60) + +--- + +### CHAIR + +> **CHAIR**: `9` + +Defined in: [types/imageSegmentation.ts:61](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L61) + +--- + +### COW + +> **COW**: `10` + +Defined in: [types/imageSegmentation.ts:62](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L62) + +--- + +### DININGTABLE + +> **DININGTABLE**: `11` + +Defined in: [types/imageSegmentation.ts:63](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L63) + +--- + +### DOG + +> **DOG**: `12` + +Defined in: [types/imageSegmentation.ts:64](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L64) + +--- + +### HORSE + +> **HORSE**: `13` + +Defined in: [types/imageSegmentation.ts:65](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L65) + +--- + +### MOTORBIKE + +> **MOTORBIKE**: `14` + +Defined in: [types/imageSegmentation.ts:66](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L66) + +--- + +### PERSON + +> **PERSON**: `15` + +Defined in: [types/imageSegmentation.ts:67](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L67) + +--- + +### POTTEDPLANT + +> **POTTEDPLANT**: `16` + +Defined in: [types/imageSegmentation.ts:68](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L68) + +--- + +### SHEEP + +> **SHEEP**: `17` + +Defined in: [types/imageSegmentation.ts:69](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L69) + +--- + +### SOFA + +> **SOFA**: `18` + +Defined in: [types/imageSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L70) + +--- + +### TRAIN + +> **TRAIN**: `19` + +Defined in: [types/imageSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L71) + +--- + +### TVMONITOR + +> **TVMONITOR**: `20` + +Defined in: [types/imageSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/imageSegmentation.ts#L72) diff --git a/docs/docs/06-api-reference/enumerations/DeeplabLabel_LOCAL_24210.md b/docs/docs/06-api-reference/enumerations/DeeplabLabel_LOCAL_24210.md new file mode 100644 index 000000000..7fc8ec2c2 --- /dev/null +++ b/docs/docs/06-api-reference/enumerations/DeeplabLabel_LOCAL_24210.md @@ -0,0 +1,173 @@ +# Enumeration: DeeplabLabel + +Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) + +Labels used in the DeepLab semantic segmentation model. + +## Enumeration Members + +### AEROPLANE + +> **AEROPLANE**: `1` + +Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) + +--- + +### BACKGROUND + +> **BACKGROUND**: `0` + +Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) + +--- + +### BICYCLE + +> **BICYCLE**: `2` + +Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) + +--- + +### BIRD + +> **BIRD**: `3` + +Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) + +--- + +### BOAT + +> **BOAT**: `4` + +Defined in: [types/semanticSegmentation.ts:75](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L75) + +--- + +### BOTTLE + +> **BOTTLE**: `5` + +Defined in: [types/semanticSegmentation.ts:76](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L76) + +--- + +### BUS + +> **BUS**: `6` + +Defined in: [types/semanticSegmentation.ts:77](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L77) + +--- + +### CAR + +> **CAR**: `7` + +Defined in: [types/semanticSegmentation.ts:78](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L78) + +--- + +### CAT + +> **CAT**: `8` + +Defined in: [types/semanticSegmentation.ts:79](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L79) + +--- + +### CHAIR + +> **CHAIR**: `9` + +Defined in: [types/semanticSegmentation.ts:80](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L80) + +--- + +### COW + +> **COW**: `10` + +Defined in: [types/semanticSegmentation.ts:81](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L81) + +--- + +### DININGTABLE + +> **DININGTABLE**: `11` + +Defined in: [types/semanticSegmentation.ts:82](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L82) + +--- + +### DOG + +> **DOG**: `12` + +Defined in: [types/semanticSegmentation.ts:83](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L83) + +--- + +### HORSE + +> **HORSE**: `13` + +Defined in: [types/semanticSegmentation.ts:84](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L84) + +--- + +### MOTORBIKE + +> **MOTORBIKE**: `14` + +Defined in: [types/semanticSegmentation.ts:85](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L85) + +--- + +### PERSON + +> **PERSON**: `15` + +Defined in: [types/semanticSegmentation.ts:86](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L86) + +--- + +### POTTEDPLANT + +> **POTTEDPLANT**: `16` + +Defined in: [types/semanticSegmentation.ts:87](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L87) + +--- + +### SHEEP + +> **SHEEP**: `17` + +Defined in: [types/semanticSegmentation.ts:88](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L88) + +--- + +### SOFA + +> **SOFA**: `18` + +Defined in: [types/semanticSegmentation.ts:89](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L89) + +--- + +### TRAIN + +> **TRAIN**: `19` + +Defined in: [types/semanticSegmentation.ts:90](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L90) + +--- + +### TVMONITOR + +> **TVMONITOR**: `20` + +Defined in: [types/semanticSegmentation.ts:91](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L91) diff --git a/docs/docs/06-api-reference/enumerations/DeeplabLabel_REMOTE_24210.md b/docs/docs/06-api-reference/enumerations/DeeplabLabel_REMOTE_24210.md new file mode 100644 index 000000000..b23c7ce9c --- /dev/null +++ b/docs/docs/06-api-reference/enumerations/DeeplabLabel_REMOTE_24210.md @@ -0,0 +1,173 @@ +# Enumeration: DeeplabLabel + +Defined in: [types/semanticSegmentation.ts:53](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L53) + +Labels used in the DeepLab image segmentation model. + +## Enumeration Members + +### AEROPLANE + +> **AEROPLANE**: `1` + +Defined in: [types/semanticSegmentation.ts:55](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L55) + +--- + +### BACKGROUND + +> **BACKGROUND**: `0` + +Defined in: [types/semanticSegmentation.ts:54](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L54) + +--- + +### BICYCLE + +> **BICYCLE**: `2` + +Defined in: [types/semanticSegmentation.ts:56](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L56) + +--- + +### BIRD + +> **BIRD**: `3` + +Defined in: [types/semanticSegmentation.ts:57](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L57) + +--- + +### BOAT + +> **BOAT**: `4` + +Defined in: [types/semanticSegmentation.ts:58](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L58) + +--- + +### BOTTLE + +> **BOTTLE**: `5` + +Defined in: [types/semanticSegmentation.ts:59](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L59) + +--- + +### BUS + +> **BUS**: `6` + +Defined in: [types/semanticSegmentation.ts:60](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L60) + +--- + +### CAR + +> **CAR**: `7` + +Defined in: [types/semanticSegmentation.ts:61](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L61) + +--- + +### CAT + +> **CAT**: `8` + +Defined in: [types/semanticSegmentation.ts:62](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L62) + +--- + +### CHAIR + +> **CHAIR**: `9` + +Defined in: [types/semanticSegmentation.ts:63](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L63) + +--- + +### COW + +> **COW**: `10` + +Defined in: [types/semanticSegmentation.ts:64](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L64) + +--- + +### DININGTABLE + +> **DININGTABLE**: `11` + +Defined in: [types/semanticSegmentation.ts:65](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L65) + +--- + +### DOG + +> **DOG**: `12` + +Defined in: [types/semanticSegmentation.ts:66](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L66) + +--- + +### HORSE + +> **HORSE**: `13` + +Defined in: [types/semanticSegmentation.ts:67](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L67) + +--- + +### MOTORBIKE + +> **MOTORBIKE**: `14` + +Defined in: [types/semanticSegmentation.ts:68](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L68) + +--- + +### PERSON + +> **PERSON**: `15` + +Defined in: [types/semanticSegmentation.ts:69](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L69) + +--- + +### POTTEDPLANT + +> **POTTEDPLANT**: `16` + +Defined in: [types/semanticSegmentation.ts:70](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L70) + +--- + +### SHEEP + +> **SHEEP**: `17` + +Defined in: [types/semanticSegmentation.ts:71](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L71) + +--- + +### SOFA + +> **SOFA**: `18` + +Defined in: [types/semanticSegmentation.ts:72](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L72) + +--- + +### TRAIN + +> **TRAIN**: `19` + +Defined in: [types/semanticSegmentation.ts:73](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L73) + +--- + +### TVMONITOR + +> **TVMONITOR**: `20` + +Defined in: [types/semanticSegmentation.ts:74](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L74) diff --git a/docs/docs/06-api-reference/enumerations/SelfieSegmentationLabel.md b/docs/docs/06-api-reference/enumerations/SelfieSegmentationLabel.md index fc0434512..793c4e918 100644 --- a/docs/docs/06-api-reference/enumerations/SelfieSegmentationLabel.md +++ b/docs/docs/06-api-reference/enumerations/SelfieSegmentationLabel.md @@ -1,8 +1,8 @@ # Enumeration: SelfieSegmentationLabel -Defined in: [types/semanticSegmentation.ts:99](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L99) +Defined in: [types/semanticSegmentation.ts:82](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L82) -Labels used in the selfie semantic segmentation model. +Labels used in the selfie image segmentation model. ## Enumeration Members @@ -10,7 +10,7 @@ Labels used in the selfie semantic segmentation model. > **BACKGROUND**: `1` -Defined in: [types/semanticSegmentation.ts:101](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L101) +Defined in: [types/semanticSegmentation.ts:84](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L84) --- @@ -18,4 +18,4 @@ Defined in: [types/semanticSegmentation.ts:101](https://github.com/software-mans > **SELFIE**: `0` -Defined in: [types/semanticSegmentation.ts:100](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L100) +Defined in: [types/semanticSegmentation.ts:83](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L83) diff --git a/docs/docs/06-api-reference/interfaces/SemanticSegmentationProps.md b/docs/docs/06-api-reference/interfaces/SemanticSegmentationProps.md index 9d7f20437..5b88365e8 100644 --- a/docs/docs/06-api-reference/interfaces/SemanticSegmentationProps.md +++ b/docs/docs/06-api-reference/interfaces/SemanticSegmentationProps.md @@ -1,8 +1,8 @@ # Interface: SemanticSegmentationProps\ -Defined in: [types/semanticSegmentation.ts:113](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L113) +Defined in: [types/semanticSegmentation.ts:96](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L96) -Props for the `useSemanticSegmentation` hook. +Props for the `useImageSegmentation` hook. ## Type Parameters @@ -18,7 +18,7 @@ A [SemanticSegmentationModelSources](../type-aliases/SemanticSegmentationModelSo > **model**: `C` -Defined in: [types/semanticSegmentation.ts:116](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L116) +Defined in: [types/semanticSegmentation.ts:99](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L99) The model config containing `modelName` and `modelSource`. @@ -28,6 +28,6 @@ The model config containing `modelName` and `modelSource`. > `optional` **preventLoad**: `boolean` -Defined in: [types/semanticSegmentation.ts:117](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L117) +Defined in: [types/semanticSegmentation.ts:100](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L100) Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. diff --git a/docs/docs/06-api-reference/interfaces/SemanticSegmentationType.md b/docs/docs/06-api-reference/interfaces/SemanticSegmentationType.md index e5628b1e3..258ca90f1 100644 --- a/docs/docs/06-api-reference/interfaces/SemanticSegmentationType.md +++ b/docs/docs/06-api-reference/interfaces/SemanticSegmentationType.md @@ -1,9 +1,9 @@ # Interface: SemanticSegmentationType\ -Defined in: [types/semanticSegmentation.ts:128](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L128) +Defined in: [types/semanticSegmentation.ts:111](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L111) -Return type for the `useSemanticSegmentation` hook. -Manages the state and operations for semantic segmentation models. +Return type for the `useImageSegmentation` hook. +Manages the state and operations for image segmentation models. ## Type Parameters @@ -19,7 +19,7 @@ The [LabelEnum](../type-aliases/LabelEnum.md) representing the model's class lab > **downloadProgress**: `number` -Defined in: [types/semanticSegmentation.ts:147](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L147) +Defined in: [types/semanticSegmentation.ts:130](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L130) Represents the download progress of the model binary as a value between 0 and 1. @@ -29,7 +29,7 @@ Represents the download progress of the model binary as a value between 0 and 1. > **error**: [`RnExecutorchError`](../classes/RnExecutorchError.md) \| `null` -Defined in: [types/semanticSegmentation.ts:132](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L132) +Defined in: [types/semanticSegmentation.ts:115](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L115) Contains the error object if the model failed to load, download, or encountered a runtime error during segmentation. @@ -39,7 +39,7 @@ Contains the error object if the model failed to load, download, or encountered > **forward**: \<`K`\>(`imageSource`, `classesOfInterest?`, `resizeToInput?`) => `Promise`\<`Record`\<`"ARGMAX"`, `Int32Array`\<`ArrayBufferLike`\>\> & `Record`\<`K`, `Float32Array`\<`ArrayBufferLike`\>\>\> -Defined in: [types/semanticSegmentation.ts:157](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L157) +Defined in: [types/semanticSegmentation.ts:140](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L140) Executes the model's forward pass to perform semantic segmentation on the provided image. @@ -85,7 +85,7 @@ If the model is not loaded or is currently processing another image. > **isGenerating**: `boolean` -Defined in: [types/semanticSegmentation.ts:142](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L142) +Defined in: [types/semanticSegmentation.ts:125](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L125) Indicates whether the model is currently processing an image. @@ -95,6 +95,6 @@ Indicates whether the model is currently processing an image. > **isReady**: `boolean` -Defined in: [types/semanticSegmentation.ts:137](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L137) +Defined in: [types/semanticSegmentation.ts:120](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L120) Indicates whether the segmentation model is loaded and ready to process images. diff --git a/docs/docs/06-api-reference/type-aliases/ModelNameOf.md b/docs/docs/06-api-reference/type-aliases/ModelNameOf.md index cfc2dfcd0..1e53b3a57 100644 --- a/docs/docs/06-api-reference/type-aliases/ModelNameOf.md +++ b/docs/docs/06-api-reference/type-aliases/ModelNameOf.md @@ -2,7 +2,7 @@ > **ModelNameOf**\<`C`\> = `C`\[`"modelName"`\] -Defined in: [types/semanticSegmentation.ts:62](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L62) +Defined in: [types/semanticSegmentation.ts:45](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L45) Extracts the model name from a [SemanticSegmentationModelSources](SemanticSegmentationModelSources.md) config object. diff --git a/docs/docs/06-api-reference/type-aliases/SegmentationLabels.md b/docs/docs/06-api-reference/type-aliases/SegmentationLabels.md index eaa40fe6a..48749fbb9 100644 --- a/docs/docs/06-api-reference/type-aliases/SegmentationLabels.md +++ b/docs/docs/06-api-reference/type-aliases/SegmentationLabels.md @@ -2,7 +2,7 @@ > **SegmentationLabels**\<`M`\> = `ModelConfigsType`\[`M`\]\[`"labelMap"`\] -Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:55](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L55) +Defined in: [modules/computer_vision/SemanticSegmentationModule.ts:39](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts#L39) Resolves the [LabelEnum](LabelEnum.md) for a given built-in model name. diff --git a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationConfig.md b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationConfig.md index 72651f4bf..0f79ad9ef 100644 --- a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationConfig.md +++ b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationConfig.md @@ -4,7 +4,7 @@ Defined in: [types/semanticSegmentation.ts:15](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L15) -Configuration for a custom semantic segmentation model. +Configuration for a custom segmentation model. ## Type Parameters diff --git a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelName.md b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelName.md index e99d28b75..462b1c3a3 100644 --- a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelName.md +++ b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelName.md @@ -2,7 +2,7 @@ > **SemanticSegmentationModelName** = [`SemanticSegmentationModelSources`](SemanticSegmentationModelSources.md)\[`"modelName"`\] -Defined in: [types/semanticSegmentation.ts:54](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L54) +Defined in: [types/semanticSegmentation.ts:37](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L37) -Union of all built-in semantic segmentation model names -(e.g. `'deeplab-v3-resnet50'`, `'selfie-segmentation'`). +Union of all built-in segmentation model names +(e.g. `'deeplab-v3'`, `'selfie-segmentation'`). diff --git a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelSources.md b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelSources.md index d59e3bb04..6ea4d19ed 100644 --- a/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelSources.md +++ b/docs/docs/06-api-reference/type-aliases/SemanticSegmentationModelSources.md @@ -1,9 +1,9 @@ # Type Alias: SemanticSegmentationModelSources -> **SemanticSegmentationModelSources** = \{ `modelName`: `"deeplab-v3-resnet50"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"deeplab-v3-resnet101"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"deeplab-v3-mobilenet-v3-large"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"lraspp-mobilenet-v3-large"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"fcn-resnet50"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"fcn-resnet101"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"deeplab-v3-resnet50-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"deeplab-v3-resnet101-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"deeplab-v3-mobilenet-v3-large-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"lraspp-mobilenet-v3-large-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"fcn-resnet50-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"fcn-resnet101-quantized"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"selfie-segmentation"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} +> **SemanticSegmentationModelSources** = \{ `modelName`: `"deeplab-v3"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} \| \{ `modelName`: `"selfie-segmentation"`; `modelSource`: [`ResourceSource`](ResourceSource.md); \} Defined in: [types/semanticSegmentation.ts:27](https://github.com/software-mansion/react-native-executorch/blob/main/packages/react-native-executorch/src/types/semanticSegmentation.ts#L27) -Per-model config for [SemanticSegmentationModule.fromModelName](../classes/SemanticSegmentationModule.md#frommodelname). +Per-model config for ImageSegmentationModule.fromModelName. Each model name maps to its required fields. Add new union members here when a model needs extra sources or options. diff --git a/docs/docs/06-api-reference/typedoc-sidebar.cjs b/docs/docs/06-api-reference/typedoc-sidebar.cjs index 676ba4747..56c6da85c 100644 --- a/docs/docs/06-api-reference/typedoc-sidebar.cjs +++ b/docs/docs/06-api-reference/typedoc-sidebar.cjs @@ -1,4 +1,4 @@ // @ts-check /** @type {import("@docusaurus/plugin-content-docs").SidebarsConfig} */ -const typedocSidebar = {items:[{type:"category",label:"Hooks",items:[{type:"doc",id:"06-api-reference/functions/useClassification",label:"useClassification"},{type:"doc",id:"06-api-reference/functions/useExecutorchModule",label:"useExecutorchModule"},{type:"doc",id:"06-api-reference/functions/useImageEmbeddings",label:"useImageEmbeddings"},{type:"doc",id:"06-api-reference/functions/useLLM",label:"useLLM"},{type:"doc",id:"06-api-reference/functions/useObjectDetection",label:"useObjectDetection"},{type:"doc",id:"06-api-reference/functions/useOCR",label:"useOCR"},{type:"doc",id:"06-api-reference/functions/useSemanticSegmentation",label:"useSemanticSegmentation"},{type:"doc",id:"06-api-reference/functions/useSpeechToText",label:"useSpeechToText"},{type:"doc",id:"06-api-reference/functions/useStyleTransfer",label:"useStyleTransfer"},{type:"doc",id:"06-api-reference/functions/useTextEmbeddings",label:"useTextEmbeddings"},{type:"doc",id:"06-api-reference/functions/useTextToImage",label:"useTextToImage"},{type:"doc",id:"06-api-reference/functions/useTextToSpeech",label:"useTextToSpeech"},{type:"doc",id:"06-api-reference/functions/useTokenizer",label:"useTokenizer"},{type:"doc",id:"06-api-reference/functions/useVAD",label:"useVAD"},{type:"doc",id:"06-api-reference/functions/useVerticalOCR",label:"useVerticalOCR"}]},{type:"category",label:"Interfaces",items:[{type:"doc",id:"06-api-reference/interfaces/ResourceSourceExtended",label:"ResourceSourceExtended"}]},{type:"category",label:"Models - Classification",items:[{type:"doc",id:"06-api-reference/variables/EFFICIENTNET_V2_S",label:"EFFICIENTNET_V2_S"}]},{type:"category",label:"Models - Image Embeddings",items:[{type:"doc",id:"06-api-reference/variables/CLIP_VIT_BASE_PATCH32_IMAGE",label:"CLIP_VIT_BASE_PATCH32_IMAGE"}]},{type:"category",label:"Models - Image Generation",items:[{type:"doc",id:"06-api-reference/variables/BK_SDM_TINY_VPRED_256",label:"BK_SDM_TINY_VPRED_256"},{type:"doc",id:"06-api-reference/variables/BK_SDM_TINY_VPRED_512",label:"BK_SDM_TINY_VPRED_512"}]},{type:"category",label:"Models - LMM",items:[{type:"doc",id:"06-api-reference/variables/HAMMER2_1_0_5B",label:"HAMMER2_1_0_5B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_0_5B_QUANTIZED",label:"HAMMER2_1_0_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_1_5B",label:"HAMMER2_1_1_5B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_1_5B_QUANTIZED",label:"HAMMER2_1_1_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_3B",label:"HAMMER2_1_3B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_3B_QUANTIZED",label:"HAMMER2_1_3B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/LFM2_5_1_2B_INSTRUCT",label:"LFM2_5_1_2B_INSTRUCT"},{type:"doc",id:"06-api-reference/variables/LFM2_5_1_2B_INSTRUCT_QUANTIZED",label:"LFM2_5_1_2B_INSTRUCT_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B",label:"LLAMA3_2_1B"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B_QLORA",label:"LLAMA3_2_1B_QLORA"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B_SPINQUANT",label:"LLAMA3_2_1B_SPINQUANT"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B",label:"LLAMA3_2_3B"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B_QLORA",label:"LLAMA3_2_3B_QLORA"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B_SPINQUANT",label:"LLAMA3_2_3B_SPINQUANT"},{type:"doc",id:"06-api-reference/variables/PHI_4_MINI_4B",label:"PHI_4_MINI_4B"},{type:"doc",id:"06-api-reference/variables/PHI_4_MINI_4B_QUANTIZED",label:"PHI_4_MINI_4B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_0_5B",label:"QWEN2_5_0_5B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_0_5B_QUANTIZED",label:"QWEN2_5_0_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_1_5B",label:"QWEN2_5_1_5B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_1_5B_QUANTIZED",label:"QWEN2_5_1_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_3B",label:"QWEN2_5_3B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_3B_QUANTIZED",label:"QWEN2_5_3B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_0_6B",label:"QWEN3_0_6B"},{type:"doc",id:"06-api-reference/variables/QWEN3_0_6B_QUANTIZED",label:"QWEN3_0_6B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_1_7B",label:"QWEN3_1_7B"},{type:"doc",id:"06-api-reference/variables/QWEN3_1_7B_QUANTIZED",label:"QWEN3_1_7B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_4B",label:"QWEN3_4B"},{type:"doc",id:"06-api-reference/variables/QWEN3_4B_QUANTIZED",label:"QWEN3_4B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_1_7B",label:"SMOLLM2_1_1_7B"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_1_7B_QUANTIZED",label:"SMOLLM2_1_1_7B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_135M",label:"SMOLLM2_1_135M"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_135M_QUANTIZED",label:"SMOLLM2_1_135M_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_360M",label:"SMOLLM2_1_360M"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_360M_QUANTIZED",label:"SMOLLM2_1_360M_QUANTIZED"}]},{type:"category",label:"Models - Object Detection",items:[{type:"doc",id:"06-api-reference/variables/SSDLITE_320_MOBILENET_V3_LARGE",label:"SSDLITE_320_MOBILENET_V3_LARGE"}]},{type:"category",label:"Models - Semantic Segmentation",items:[{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_MOBILENET_V3_LARGE",label:"DEEPLAB_V3_MOBILENET_V3_LARGE"},{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_MOBILENET_V3_LARGE_QUANTIZED",label:"DEEPLAB_V3_MOBILENET_V3_LARGE_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_RESNET101",label:"DEEPLAB_V3_RESNET101"},{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_RESNET101_QUANTIZED",label:"DEEPLAB_V3_RESNET101_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_RESNET50",label:"DEEPLAB_V3_RESNET50"},{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_RESNET50_QUANTIZED",label:"DEEPLAB_V3_RESNET50_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/FCN_RESNET101",label:"FCN_RESNET101"},{type:"doc",id:"06-api-reference/variables/FCN_RESNET101_QUANTIZED",label:"FCN_RESNET101_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/FCN_RESNET50",label:"FCN_RESNET50"},{type:"doc",id:"06-api-reference/variables/FCN_RESNET50_QUANTIZED",label:"FCN_RESNET50_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/LRASPP_MOBILENET_V3_LARGE",label:"LRASPP_MOBILENET_V3_LARGE"},{type:"doc",id:"06-api-reference/variables/LRASPP_MOBILENET_V3_LARGE_QUANTIZED",label:"LRASPP_MOBILENET_V3_LARGE_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SELFIE_SEGMENTATION",label:"SELFIE_SEGMENTATION"}]},{type:"category",label:"Models - Speech To Text",items:[{type:"doc",id:"06-api-reference/variables/WHISPER_BASE",label:"WHISPER_BASE"},{type:"doc",id:"06-api-reference/variables/WHISPER_BASE_EN",label:"WHISPER_BASE_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_SMALL",label:"WHISPER_SMALL"},{type:"doc",id:"06-api-reference/variables/WHISPER_SMALL_EN",label:"WHISPER_SMALL_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY",label:"WHISPER_TINY"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY_EN",label:"WHISPER_TINY_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY_EN_QUANTIZED",label:"WHISPER_TINY_EN_QUANTIZED"}]},{type:"category",label:"Models - Style Transfer",items:[{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_CANDY",label:"STYLE_TRANSFER_CANDY"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_MOSAIC",label:"STYLE_TRANSFER_MOSAIC"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_RAIN_PRINCESS",label:"STYLE_TRANSFER_RAIN_PRINCESS"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_UDNIE",label:"STYLE_TRANSFER_UDNIE"}]},{type:"category",label:"Models - Text Embeddings",items:[{type:"doc",id:"06-api-reference/variables/ALL_MINILM_L6_V2",label:"ALL_MINILM_L6_V2"},{type:"doc",id:"06-api-reference/variables/ALL_MPNET_BASE_V2",label:"ALL_MPNET_BASE_V2"},{type:"doc",id:"06-api-reference/variables/CLIP_VIT_BASE_PATCH32_TEXT",label:"CLIP_VIT_BASE_PATCH32_TEXT"},{type:"doc",id:"06-api-reference/variables/MULTI_QA_MINILM_L6_COS_V1",label:"MULTI_QA_MINILM_L6_COS_V1"},{type:"doc",id:"06-api-reference/variables/MULTI_QA_MPNET_BASE_DOT_V1",label:"MULTI_QA_MPNET_BASE_DOT_V1"}]},{type:"category",label:"Models - Text to Speech",items:[{type:"doc",id:"06-api-reference/variables/KOKORO_MEDIUM",label:"KOKORO_MEDIUM"},{type:"doc",id:"06-api-reference/variables/KOKORO_SMALL",label:"KOKORO_SMALL"}]},{type:"category",label:"Models - Voice Activity Detection",items:[{type:"doc",id:"06-api-reference/variables/FSMN_VAD",label:"FSMN_VAD"}]},{type:"category",label:"OCR Supported Alphabets",items:[{type:"doc",id:"06-api-reference/variables/OCR_ABAZA",label:"OCR_ABAZA"},{type:"doc",id:"06-api-reference/variables/OCR_ADYGHE",label:"OCR_ADYGHE"},{type:"doc",id:"06-api-reference/variables/OCR_AFRIKAANS",label:"OCR_AFRIKAANS"},{type:"doc",id:"06-api-reference/variables/OCR_ALBANIAN",label:"OCR_ALBANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_AVAR",label:"OCR_AVAR"},{type:"doc",id:"06-api-reference/variables/OCR_AZERBAIJANI",label:"OCR_AZERBAIJANI"},{type:"doc",id:"06-api-reference/variables/OCR_BELARUSIAN",label:"OCR_BELARUSIAN"},{type:"doc",id:"06-api-reference/variables/OCR_BOSNIAN",label:"OCR_BOSNIAN"},{type:"doc",id:"06-api-reference/variables/OCR_BULGARIAN",label:"OCR_BULGARIAN"},{type:"doc",id:"06-api-reference/variables/OCR_CHECHEN",label:"OCR_CHECHEN"},{type:"doc",id:"06-api-reference/variables/OCR_CROATIAN",label:"OCR_CROATIAN"},{type:"doc",id:"06-api-reference/variables/OCR_CZECH",label:"OCR_CZECH"},{type:"doc",id:"06-api-reference/variables/OCR_DANISH",label:"OCR_DANISH"},{type:"doc",id:"06-api-reference/variables/OCR_DARGWA",label:"OCR_DARGWA"},{type:"doc",id:"06-api-reference/variables/OCR_DUTCH",label:"OCR_DUTCH"},{type:"doc",id:"06-api-reference/variables/OCR_ENGLISH",label:"OCR_ENGLISH"},{type:"doc",id:"06-api-reference/variables/OCR_ESTONIAN",label:"OCR_ESTONIAN"},{type:"doc",id:"06-api-reference/variables/OCR_FRENCH",label:"OCR_FRENCH"},{type:"doc",id:"06-api-reference/variables/OCR_GERMAN",label:"OCR_GERMAN"},{type:"doc",id:"06-api-reference/variables/OCR_HUNGARIAN",label:"OCR_HUNGARIAN"},{type:"doc",id:"06-api-reference/variables/OCR_ICELANDIC",label:"OCR_ICELANDIC"},{type:"doc",id:"06-api-reference/variables/OCR_INDONESIAN",label:"OCR_INDONESIAN"},{type:"doc",id:"06-api-reference/variables/OCR_INGUSH",label:"OCR_INGUSH"},{type:"doc",id:"06-api-reference/variables/OCR_IRISH",label:"OCR_IRISH"},{type:"doc",id:"06-api-reference/variables/OCR_ITALIAN",label:"OCR_ITALIAN"},{type:"doc",id:"06-api-reference/variables/OCR_JAPANESE",label:"OCR_JAPANESE"},{type:"doc",id:"06-api-reference/variables/OCR_KANNADA",label:"OCR_KANNADA"},{type:"doc",id:"06-api-reference/variables/OCR_KARBADIAN",label:"OCR_KARBADIAN"},{type:"doc",id:"06-api-reference/variables/OCR_KOREAN",label:"OCR_KOREAN"},{type:"doc",id:"06-api-reference/variables/OCR_KURDISH",label:"OCR_KURDISH"},{type:"doc",id:"06-api-reference/variables/OCR_LAK",label:"OCR_LAK"},{type:"doc",id:"06-api-reference/variables/OCR_LATIN",label:"OCR_LATIN"},{type:"doc",id:"06-api-reference/variables/OCR_LATVIAN",label:"OCR_LATVIAN"},{type:"doc",id:"06-api-reference/variables/OCR_LEZGHIAN",label:"OCR_LEZGHIAN"},{type:"doc",id:"06-api-reference/variables/OCR_LITHUANIAN",label:"OCR_LITHUANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_MALAY",label:"OCR_MALAY"},{type:"doc",id:"06-api-reference/variables/OCR_MALTESE",label:"OCR_MALTESE"},{type:"doc",id:"06-api-reference/variables/OCR_MAORI",label:"OCR_MAORI"},{type:"doc",id:"06-api-reference/variables/OCR_MONGOLIAN",label:"OCR_MONGOLIAN"},{type:"doc",id:"06-api-reference/variables/OCR_NORWEGIAN",label:"OCR_NORWEGIAN"},{type:"doc",id:"06-api-reference/variables/OCR_OCCITAN",label:"OCR_OCCITAN"},{type:"doc",id:"06-api-reference/variables/OCR_PALI",label:"OCR_PALI"},{type:"doc",id:"06-api-reference/variables/OCR_POLISH",label:"OCR_POLISH"},{type:"doc",id:"06-api-reference/variables/OCR_PORTUGUESE",label:"OCR_PORTUGUESE"},{type:"doc",id:"06-api-reference/variables/OCR_ROMANIAN",label:"OCR_ROMANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_RUSSIAN",label:"OCR_RUSSIAN"},{type:"doc",id:"06-api-reference/variables/OCR_SERBIAN_CYRILLIC",label:"OCR_SERBIAN_CYRILLIC"},{type:"doc",id:"06-api-reference/variables/OCR_SERBIAN_LATIN",label:"OCR_SERBIAN_LATIN"},{type:"doc",id:"06-api-reference/variables/OCR_SIMPLIFIED_CHINESE",label:"OCR_SIMPLIFIED_CHINESE"},{type:"doc",id:"06-api-reference/variables/OCR_SLOVAK",label:"OCR_SLOVAK"},{type:"doc",id:"06-api-reference/variables/OCR_SLOVENIAN",label:"OCR_SLOVENIAN"},{type:"doc",id:"06-api-reference/variables/OCR_SPANISH",label:"OCR_SPANISH"},{type:"doc",id:"06-api-reference/variables/OCR_SWAHILI",label:"OCR_SWAHILI"},{type:"doc",id:"06-api-reference/variables/OCR_SWEDISH",label:"OCR_SWEDISH"},{type:"doc",id:"06-api-reference/variables/OCR_TABASSARAN",label:"OCR_TABASSARAN"},{type:"doc",id:"06-api-reference/variables/OCR_TAGALOG",label:"OCR_TAGALOG"},{type:"doc",id:"06-api-reference/variables/OCR_TAJIK",label:"OCR_TAJIK"},{type:"doc",id:"06-api-reference/variables/OCR_TELUGU",label:"OCR_TELUGU"},{type:"doc",id:"06-api-reference/variables/OCR_TURKISH",label:"OCR_TURKISH"},{type:"doc",id:"06-api-reference/variables/OCR_UKRAINIAN",label:"OCR_UKRAINIAN"},{type:"doc",id:"06-api-reference/variables/OCR_UZBEK",label:"OCR_UZBEK"},{type:"doc",id:"06-api-reference/variables/OCR_VIETNAMESE",label:"OCR_VIETNAMESE"},{type:"doc",id:"06-api-reference/variables/OCR_WELSH",label:"OCR_WELSH"}]},{type:"category",label:"Other",items:[{type:"doc",id:"06-api-reference/enumerations/RnExecutorchErrorCode",label:"RnExecutorchErrorCode"},{type:"doc",id:"06-api-reference/classes/Logger",label:"Logger"},{type:"doc",id:"06-api-reference/classes/RnExecutorchError",label:"RnExecutorchError"}]},{type:"category",label:"TTS Supported Voices",items:[{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_HEART",label:"KOKORO_VOICE_AF_HEART"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_RIVER",label:"KOKORO_VOICE_AF_RIVER"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_SARAH",label:"KOKORO_VOICE_AF_SARAH"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_ADAM",label:"KOKORO_VOICE_AM_ADAM"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_MICHAEL",label:"KOKORO_VOICE_AM_MICHAEL"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_SANTA",label:"KOKORO_VOICE_AM_SANTA"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_BF_EMMA",label:"KOKORO_VOICE_BF_EMMA"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_BM_DANIEL",label:"KOKORO_VOICE_BM_DANIEL"}]},{type:"category",label:"Types",items:[{type:"doc",id:"06-api-reference/enumerations/CocoLabel",label:"CocoLabel"},{type:"doc",id:"06-api-reference/enumerations/DeeplabLabel",label:"DeeplabLabel"},{type:"doc",id:"06-api-reference/enumerations/DownloadStatus",label:"DownloadStatus"},{type:"doc",id:"06-api-reference/enumerations/HTTP_CODE",label:"HTTP_CODE"},{type:"doc",id:"06-api-reference/enumerations/ScalarType",label:"ScalarType"},{type:"doc",id:"06-api-reference/enumerations/SelfieSegmentationLabel",label:"SelfieSegmentationLabel"},{type:"doc",id:"06-api-reference/enumerations/SourceType",label:"SourceType"},{type:"doc",id:"06-api-reference/interfaces/Bbox",label:"Bbox"},{type:"doc",id:"06-api-reference/interfaces/ChatConfig",label:"ChatConfig"},{type:"doc",id:"06-api-reference/interfaces/ClassificationProps",label:"ClassificationProps"},{type:"doc",id:"06-api-reference/interfaces/ClassificationType",label:"ClassificationType"},{type:"doc",id:"06-api-reference/interfaces/ContextStrategy",label:"ContextStrategy"},{type:"doc",id:"06-api-reference/interfaces/DecodingOptions",label:"DecodingOptions"},{type:"doc",id:"06-api-reference/interfaces/Detection",label:"Detection"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchModuleProps",label:"ExecutorchModuleProps"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchModuleType",label:"ExecutorchModuleType"},{type:"doc",id:"06-api-reference/interfaces/GenerationConfig",label:"GenerationConfig"},{type:"doc",id:"06-api-reference/interfaces/ImageEmbeddingsProps",label:"ImageEmbeddingsProps"},{type:"doc",id:"06-api-reference/interfaces/ImageEmbeddingsType",label:"ImageEmbeddingsType"},{type:"doc",id:"06-api-reference/interfaces/KokoroConfig",label:"KokoroConfig"},{type:"doc",id:"06-api-reference/interfaces/KokoroVoiceExtras",label:"KokoroVoiceExtras"},{type:"doc",id:"06-api-reference/interfaces/LLMConfig",label:"LLMConfig"},{type:"doc",id:"06-api-reference/interfaces/LLMProps",label:"LLMProps"},{type:"doc",id:"06-api-reference/interfaces/LLMType",label:"LLMType"},{type:"doc",id:"06-api-reference/interfaces/Message",label:"Message"},{type:"doc",id:"06-api-reference/interfaces/ObjectDetectionProps",label:"ObjectDetectionProps"},{type:"doc",id:"06-api-reference/interfaces/ObjectDetectionType",label:"ObjectDetectionType"},{type:"doc",id:"06-api-reference/interfaces/OCRDetection",label:"OCRDetection"},{type:"doc",id:"06-api-reference/interfaces/OCRProps",label:"OCRProps"},{type:"doc",id:"06-api-reference/interfaces/OCRType",label:"OCRType"},{type:"doc",id:"06-api-reference/interfaces/Point",label:"Point"},{type:"doc",id:"06-api-reference/interfaces/Segment",label:"Segment"},{type:"doc",id:"06-api-reference/interfaces/SemanticSegmentationProps",label:"SemanticSegmentationProps"},{type:"doc",id:"06-api-reference/interfaces/SemanticSegmentationType",label:"SemanticSegmentationType"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextModelConfig",label:"SpeechToTextModelConfig"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextProps",label:"SpeechToTextProps"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextType",label:"SpeechToTextType"},{type:"doc",id:"06-api-reference/interfaces/StyleTransferProps",label:"StyleTransferProps"},{type:"doc",id:"06-api-reference/interfaces/StyleTransferType",label:"StyleTransferType"},{type:"doc",id:"06-api-reference/interfaces/TensorPtr",label:"TensorPtr"},{type:"doc",id:"06-api-reference/interfaces/TextEmbeddingsProps",label:"TextEmbeddingsProps"},{type:"doc",id:"06-api-reference/interfaces/TextEmbeddingsType",label:"TextEmbeddingsType"},{type:"doc",id:"06-api-reference/interfaces/TextToImageProps",label:"TextToImageProps"},{type:"doc",id:"06-api-reference/interfaces/TextToImageType",label:"TextToImageType"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechConfig",label:"TextToSpeechConfig"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechInput",label:"TextToSpeechInput"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechProps",label:"TextToSpeechProps"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechStreamingInput",label:"TextToSpeechStreamingInput"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechType",label:"TextToSpeechType"},{type:"doc",id:"06-api-reference/interfaces/TokenizerProps",label:"TokenizerProps"},{type:"doc",id:"06-api-reference/interfaces/TokenizerType",label:"TokenizerType"},{type:"doc",id:"06-api-reference/interfaces/ToolCall",label:"ToolCall"},{type:"doc",id:"06-api-reference/interfaces/ToolsConfig",label:"ToolsConfig"},{type:"doc",id:"06-api-reference/interfaces/TranscriptionResult",label:"TranscriptionResult"},{type:"doc",id:"06-api-reference/interfaces/TranscriptionSegment",label:"TranscriptionSegment"},{type:"doc",id:"06-api-reference/interfaces/VADProps",label:"VADProps"},{type:"doc",id:"06-api-reference/interfaces/VADType",label:"VADType"},{type:"doc",id:"06-api-reference/interfaces/VerticalOCRProps",label:"VerticalOCRProps"},{type:"doc",id:"06-api-reference/interfaces/VoiceConfig",label:"VoiceConfig"},{type:"doc",id:"06-api-reference/interfaces/Word",label:"Word"},{type:"doc",id:"06-api-reference/type-aliases/LabelEnum",label:"LabelEnum"},{type:"doc",id:"06-api-reference/type-aliases/LLMTool",label:"LLMTool"},{type:"doc",id:"06-api-reference/type-aliases/MessageRole",label:"MessageRole"},{type:"doc",id:"06-api-reference/type-aliases/ModelNameOf",label:"ModelNameOf"},{type:"doc",id:"06-api-reference/type-aliases/OCRLanguage",label:"OCRLanguage"},{type:"doc",id:"06-api-reference/type-aliases/ResourceSource",label:"ResourceSource"},{type:"doc",id:"06-api-reference/type-aliases/SegmentationLabels",label:"SegmentationLabels"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationConfig",label:"SemanticSegmentationConfig"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationModelName",label:"SemanticSegmentationModelName"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationModelSources",label:"SemanticSegmentationModelSources"},{type:"doc",id:"06-api-reference/type-aliases/SpeechToTextLanguage",label:"SpeechToTextLanguage"},{type:"doc",id:"06-api-reference/type-aliases/TensorBuffer",label:"TensorBuffer"},{type:"doc",id:"06-api-reference/type-aliases/TextToSpeechLanguage",label:"TextToSpeechLanguage"},{type:"doc",id:"06-api-reference/type-aliases/Triple",label:"Triple"},{type:"doc",id:"06-api-reference/variables/SPECIAL_TOKENS",label:"SPECIAL_TOKENS"}]},{type:"category",label:"Typescript API",items:[{type:"doc",id:"06-api-reference/classes/ClassificationModule",label:"ClassificationModule"},{type:"doc",id:"06-api-reference/classes/ExecutorchModule",label:"ExecutorchModule"},{type:"doc",id:"06-api-reference/classes/ImageEmbeddingsModule",label:"ImageEmbeddingsModule"},{type:"doc",id:"06-api-reference/classes/LLMModule",label:"LLMModule"},{type:"doc",id:"06-api-reference/classes/ObjectDetectionModule",label:"ObjectDetectionModule"},{type:"doc",id:"06-api-reference/classes/OCRModule",label:"OCRModule"},{type:"doc",id:"06-api-reference/classes/SemanticSegmentationModule",label:"SemanticSegmentationModule"},{type:"doc",id:"06-api-reference/classes/SpeechToTextModule",label:"SpeechToTextModule"},{type:"doc",id:"06-api-reference/classes/StyleTransferModule",label:"StyleTransferModule"},{type:"doc",id:"06-api-reference/classes/TextEmbeddingsModule",label:"TextEmbeddingsModule"},{type:"doc",id:"06-api-reference/classes/TextToImageModule",label:"TextToImageModule"},{type:"doc",id:"06-api-reference/classes/TextToSpeechModule",label:"TextToSpeechModule"},{type:"doc",id:"06-api-reference/classes/TokenizerModule",label:"TokenizerModule"},{type:"doc",id:"06-api-reference/classes/VADModule",label:"VADModule"},{type:"doc",id:"06-api-reference/classes/VerticalOCRModule",label:"VerticalOCRModule"}]},{type:"category",label:"Utilities - General",items:[{type:"category",label:"ResourceFetcherUtils",items:[{type:"category",label:"Functions",items:[{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/calculateDownloadProgress",label:"calculateDownloadProgress"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/getFilenameFromUri",label:"getFilenameFromUri"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/hashObject",label:"hashObject"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/removeFilePrefix",label:"removeFilePrefix"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/triggerHuggingFaceDownloadCounter",label:"triggerHuggingFaceDownloadCounter"}]}],link:{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/index"}},{type:"doc",id:"06-api-reference/classes/ResourceFetcher",label:"ResourceFetcher"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchConfig",label:"ExecutorchConfig"},{type:"doc",id:"06-api-reference/interfaces/ResourceFetcherAdapter",label:"ResourceFetcherAdapter"},{type:"doc",id:"06-api-reference/functions/cleanupExecutorch",label:"cleanupExecutorch"},{type:"doc",id:"06-api-reference/functions/initExecutorch",label:"initExecutorch"}]},{type:"category",label:"Utilities - LLM",items:[{type:"doc",id:"06-api-reference/variables/DEFAULT_CHAT_CONFIG",label:"DEFAULT_CHAT_CONFIG"},{type:"doc",id:"06-api-reference/variables/DEFAULT_CONTEXT_BUFFER_TOKENS",label:"DEFAULT_CONTEXT_BUFFER_TOKENS"},{type:"doc",id:"06-api-reference/variables/DEFAULT_MESSAGE_HISTORY",label:"DEFAULT_MESSAGE_HISTORY"},{type:"doc",id:"06-api-reference/variables/DEFAULT_SYSTEM_PROMPT",label:"DEFAULT_SYSTEM_PROMPT"},{type:"doc",id:"06-api-reference/variables/parseToolCall",label:"parseToolCall"},{type:"doc",id:"06-api-reference/functions/DEFAULT_STRUCTURED_OUTPUT_PROMPT",label:"DEFAULT_STRUCTURED_OUTPUT_PROMPT"},{type:"doc",id:"06-api-reference/functions/fixAndValidateStructuredOutput",label:"fixAndValidateStructuredOutput"},{type:"doc",id:"06-api-reference/functions/getStructuredOutputPrompt",label:"getStructuredOutputPrompt"}]},{type:"category",label:"Utils",items:[{type:"doc",id:"06-api-reference/classes/MessageCountContextStrategy",label:"MessageCountContextStrategy"},{type:"doc",id:"06-api-reference/classes/NoopContextStrategy",label:"NoopContextStrategy"},{type:"doc",id:"06-api-reference/classes/SlidingWindowContextStrategy",label:"SlidingWindowContextStrategy"}]}]}; +const typedocSidebar = {items:[{type:"category",label:"Hooks",items:[{type:"doc",id:"06-api-reference/functions/useClassification",label:"useClassification"},{type:"doc",id:"06-api-reference/functions/useExecutorchModule",label:"useExecutorchModule"},{type:"doc",id:"06-api-reference/functions/useImageEmbeddings",label:"useImageEmbeddings"},{type:"doc",id:"06-api-reference/functions/useLLM",label:"useLLM"},{type:"doc",id:"06-api-reference/functions/useObjectDetection",label:"useObjectDetection"},{type:"doc",id:"06-api-reference/functions/useOCR",label:"useOCR"},{type:"doc",id:"06-api-reference/functions/useSemanticSegmentation",label:"useSemanticSegmentation"},{type:"doc",id:"06-api-reference/functions/useSpeechToText",label:"useSpeechToText"},{type:"doc",id:"06-api-reference/functions/useStyleTransfer",label:"useStyleTransfer"},{type:"doc",id:"06-api-reference/functions/useTextEmbeddings",label:"useTextEmbeddings"},{type:"doc",id:"06-api-reference/functions/useTextToImage",label:"useTextToImage"},{type:"doc",id:"06-api-reference/functions/useTextToSpeech",label:"useTextToSpeech"},{type:"doc",id:"06-api-reference/functions/useTokenizer",label:"useTokenizer"},{type:"doc",id:"06-api-reference/functions/useVAD",label:"useVAD"},{type:"doc",id:"06-api-reference/functions/useVerticalOCR",label:"useVerticalOCR"}]},{type:"category",label:"Interfaces",items:[{type:"doc",id:"06-api-reference/interfaces/ResourceSourceExtended",label:"ResourceSourceExtended"}]},{type:"category",label:"Models - Classification",items:[{type:"doc",id:"06-api-reference/variables/EFFICIENTNET_V2_S",label:"EFFICIENTNET_V2_S"}]},{type:"category",label:"Models - Image Embeddings",items:[{type:"doc",id:"06-api-reference/variables/CLIP_VIT_BASE_PATCH32_IMAGE",label:"CLIP_VIT_BASE_PATCH32_IMAGE"}]},{type:"category",label:"Models - Image Generation",items:[{type:"doc",id:"06-api-reference/variables/BK_SDM_TINY_VPRED_256",label:"BK_SDM_TINY_VPRED_256"},{type:"doc",id:"06-api-reference/variables/BK_SDM_TINY_VPRED_512",label:"BK_SDM_TINY_VPRED_512"}]},{type:"category",label:"Models - Image Segmentation",items:[{type:"doc",id:"06-api-reference/variables/DEEPLAB_V3_RESNET50",label:"DEEPLAB_V3_RESNET50"},{type:"doc",id:"06-api-reference/variables/SELFIE_SEGMENTATION",label:"SELFIE_SEGMENTATION"}]},{type:"category",label:"Models - LMM",items:[{type:"doc",id:"06-api-reference/variables/HAMMER2_1_0_5B",label:"HAMMER2_1_0_5B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_0_5B_QUANTIZED",label:"HAMMER2_1_0_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_1_5B",label:"HAMMER2_1_1_5B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_1_5B_QUANTIZED",label:"HAMMER2_1_1_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_3B",label:"HAMMER2_1_3B"},{type:"doc",id:"06-api-reference/variables/HAMMER2_1_3B_QUANTIZED",label:"HAMMER2_1_3B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B",label:"LLAMA3_2_1B"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B_QLORA",label:"LLAMA3_2_1B_QLORA"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_1B_SPINQUANT",label:"LLAMA3_2_1B_SPINQUANT"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B",label:"LLAMA3_2_3B"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B_QLORA",label:"LLAMA3_2_3B_QLORA"},{type:"doc",id:"06-api-reference/variables/LLAMA3_2_3B_SPINQUANT",label:"LLAMA3_2_3B_SPINQUANT"},{type:"doc",id:"06-api-reference/variables/PHI_4_MINI_4B",label:"PHI_4_MINI_4B"},{type:"doc",id:"06-api-reference/variables/PHI_4_MINI_4B_QUANTIZED",label:"PHI_4_MINI_4B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_0_5B",label:"QWEN2_5_0_5B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_0_5B_QUANTIZED",label:"QWEN2_5_0_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_1_5B",label:"QWEN2_5_1_5B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_1_5B_QUANTIZED",label:"QWEN2_5_1_5B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_3B",label:"QWEN2_5_3B"},{type:"doc",id:"06-api-reference/variables/QWEN2_5_3B_QUANTIZED",label:"QWEN2_5_3B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_0_6B",label:"QWEN3_0_6B"},{type:"doc",id:"06-api-reference/variables/QWEN3_0_6B_QUANTIZED",label:"QWEN3_0_6B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_1_7B",label:"QWEN3_1_7B"},{type:"doc",id:"06-api-reference/variables/QWEN3_1_7B_QUANTIZED",label:"QWEN3_1_7B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/QWEN3_4B",label:"QWEN3_4B"},{type:"doc",id:"06-api-reference/variables/QWEN3_4B_QUANTIZED",label:"QWEN3_4B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_1_7B",label:"SMOLLM2_1_1_7B"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_1_7B_QUANTIZED",label:"SMOLLM2_1_1_7B_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_135M",label:"SMOLLM2_1_135M"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_135M_QUANTIZED",label:"SMOLLM2_1_135M_QUANTIZED"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_360M",label:"SMOLLM2_1_360M"},{type:"doc",id:"06-api-reference/variables/SMOLLM2_1_360M_QUANTIZED",label:"SMOLLM2_1_360M_QUANTIZED"}]},{type:"category",label:"Models - Object Detection",items:[{type:"doc",id:"06-api-reference/variables/SSDLITE_320_MOBILENET_V3_LARGE",label:"SSDLITE_320_MOBILENET_V3_LARGE"}]},{type:"category",label:"Models - Speech To Text",items:[{type:"doc",id:"06-api-reference/variables/WHISPER_BASE",label:"WHISPER_BASE"},{type:"doc",id:"06-api-reference/variables/WHISPER_BASE_EN",label:"WHISPER_BASE_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_SMALL",label:"WHISPER_SMALL"},{type:"doc",id:"06-api-reference/variables/WHISPER_SMALL_EN",label:"WHISPER_SMALL_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY",label:"WHISPER_TINY"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY_EN",label:"WHISPER_TINY_EN"},{type:"doc",id:"06-api-reference/variables/WHISPER_TINY_EN_QUANTIZED",label:"WHISPER_TINY_EN_QUANTIZED"}]},{type:"category",label:"Models - Style Transfer",items:[{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_CANDY",label:"STYLE_TRANSFER_CANDY"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_MOSAIC",label:"STYLE_TRANSFER_MOSAIC"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_RAIN_PRINCESS",label:"STYLE_TRANSFER_RAIN_PRINCESS"},{type:"doc",id:"06-api-reference/variables/STYLE_TRANSFER_UDNIE",label:"STYLE_TRANSFER_UDNIE"}]},{type:"category",label:"Models - Text Embeddings",items:[{type:"doc",id:"06-api-reference/variables/ALL_MINILM_L6_V2",label:"ALL_MINILM_L6_V2"},{type:"doc",id:"06-api-reference/variables/ALL_MPNET_BASE_V2",label:"ALL_MPNET_BASE_V2"},{type:"doc",id:"06-api-reference/variables/CLIP_VIT_BASE_PATCH32_TEXT",label:"CLIP_VIT_BASE_PATCH32_TEXT"},{type:"doc",id:"06-api-reference/variables/MULTI_QA_MINILM_L6_COS_V1",label:"MULTI_QA_MINILM_L6_COS_V1"},{type:"doc",id:"06-api-reference/variables/MULTI_QA_MPNET_BASE_DOT_V1",label:"MULTI_QA_MPNET_BASE_DOT_V1"}]},{type:"category",label:"Models - Text to Speech",items:[{type:"doc",id:"06-api-reference/variables/KOKORO_MEDIUM",label:"KOKORO_MEDIUM"},{type:"doc",id:"06-api-reference/variables/KOKORO_SMALL",label:"KOKORO_SMALL"}]},{type:"category",label:"Models - Voice Activity Detection",items:[{type:"doc",id:"06-api-reference/variables/FSMN_VAD",label:"FSMN_VAD"}]},{type:"category",label:"OCR Supported Alphabets",items:[{type:"doc",id:"06-api-reference/variables/OCR_ABAZA",label:"OCR_ABAZA"},{type:"doc",id:"06-api-reference/variables/OCR_ADYGHE",label:"OCR_ADYGHE"},{type:"doc",id:"06-api-reference/variables/OCR_AFRIKAANS",label:"OCR_AFRIKAANS"},{type:"doc",id:"06-api-reference/variables/OCR_ALBANIAN",label:"OCR_ALBANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_AVAR",label:"OCR_AVAR"},{type:"doc",id:"06-api-reference/variables/OCR_AZERBAIJANI",label:"OCR_AZERBAIJANI"},{type:"doc",id:"06-api-reference/variables/OCR_BELARUSIAN",label:"OCR_BELARUSIAN"},{type:"doc",id:"06-api-reference/variables/OCR_BOSNIAN",label:"OCR_BOSNIAN"},{type:"doc",id:"06-api-reference/variables/OCR_BULGARIAN",label:"OCR_BULGARIAN"},{type:"doc",id:"06-api-reference/variables/OCR_CHECHEN",label:"OCR_CHECHEN"},{type:"doc",id:"06-api-reference/variables/OCR_CROATIAN",label:"OCR_CROATIAN"},{type:"doc",id:"06-api-reference/variables/OCR_CZECH",label:"OCR_CZECH"},{type:"doc",id:"06-api-reference/variables/OCR_DANISH",label:"OCR_DANISH"},{type:"doc",id:"06-api-reference/variables/OCR_DARGWA",label:"OCR_DARGWA"},{type:"doc",id:"06-api-reference/variables/OCR_DUTCH",label:"OCR_DUTCH"},{type:"doc",id:"06-api-reference/variables/OCR_ENGLISH",label:"OCR_ENGLISH"},{type:"doc",id:"06-api-reference/variables/OCR_ESTONIAN",label:"OCR_ESTONIAN"},{type:"doc",id:"06-api-reference/variables/OCR_FRENCH",label:"OCR_FRENCH"},{type:"doc",id:"06-api-reference/variables/OCR_GERMAN",label:"OCR_GERMAN"},{type:"doc",id:"06-api-reference/variables/OCR_HUNGARIAN",label:"OCR_HUNGARIAN"},{type:"doc",id:"06-api-reference/variables/OCR_ICELANDIC",label:"OCR_ICELANDIC"},{type:"doc",id:"06-api-reference/variables/OCR_INDONESIAN",label:"OCR_INDONESIAN"},{type:"doc",id:"06-api-reference/variables/OCR_INGUSH",label:"OCR_INGUSH"},{type:"doc",id:"06-api-reference/variables/OCR_IRISH",label:"OCR_IRISH"},{type:"doc",id:"06-api-reference/variables/OCR_ITALIAN",label:"OCR_ITALIAN"},{type:"doc",id:"06-api-reference/variables/OCR_JAPANESE",label:"OCR_JAPANESE"},{type:"doc",id:"06-api-reference/variables/OCR_KANNADA",label:"OCR_KANNADA"},{type:"doc",id:"06-api-reference/variables/OCR_KARBADIAN",label:"OCR_KARBADIAN"},{type:"doc",id:"06-api-reference/variables/OCR_KOREAN",label:"OCR_KOREAN"},{type:"doc",id:"06-api-reference/variables/OCR_KURDISH",label:"OCR_KURDISH"},{type:"doc",id:"06-api-reference/variables/OCR_LAK",label:"OCR_LAK"},{type:"doc",id:"06-api-reference/variables/OCR_LATIN",label:"OCR_LATIN"},{type:"doc",id:"06-api-reference/variables/OCR_LATVIAN",label:"OCR_LATVIAN"},{type:"doc",id:"06-api-reference/variables/OCR_LEZGHIAN",label:"OCR_LEZGHIAN"},{type:"doc",id:"06-api-reference/variables/OCR_LITHUANIAN",label:"OCR_LITHUANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_MALAY",label:"OCR_MALAY"},{type:"doc",id:"06-api-reference/variables/OCR_MALTESE",label:"OCR_MALTESE"},{type:"doc",id:"06-api-reference/variables/OCR_MAORI",label:"OCR_MAORI"},{type:"doc",id:"06-api-reference/variables/OCR_MONGOLIAN",label:"OCR_MONGOLIAN"},{type:"doc",id:"06-api-reference/variables/OCR_NORWEGIAN",label:"OCR_NORWEGIAN"},{type:"doc",id:"06-api-reference/variables/OCR_OCCITAN",label:"OCR_OCCITAN"},{type:"doc",id:"06-api-reference/variables/OCR_PALI",label:"OCR_PALI"},{type:"doc",id:"06-api-reference/variables/OCR_POLISH",label:"OCR_POLISH"},{type:"doc",id:"06-api-reference/variables/OCR_PORTUGUESE",label:"OCR_PORTUGUESE"},{type:"doc",id:"06-api-reference/variables/OCR_ROMANIAN",label:"OCR_ROMANIAN"},{type:"doc",id:"06-api-reference/variables/OCR_RUSSIAN",label:"OCR_RUSSIAN"},{type:"doc",id:"06-api-reference/variables/OCR_SERBIAN_CYRILLIC",label:"OCR_SERBIAN_CYRILLIC"},{type:"doc",id:"06-api-reference/variables/OCR_SERBIAN_LATIN",label:"OCR_SERBIAN_LATIN"},{type:"doc",id:"06-api-reference/variables/OCR_SIMPLIFIED_CHINESE",label:"OCR_SIMPLIFIED_CHINESE"},{type:"doc",id:"06-api-reference/variables/OCR_SLOVAK",label:"OCR_SLOVAK"},{type:"doc",id:"06-api-reference/variables/OCR_SLOVENIAN",label:"OCR_SLOVENIAN"},{type:"doc",id:"06-api-reference/variables/OCR_SPANISH",label:"OCR_SPANISH"},{type:"doc",id:"06-api-reference/variables/OCR_SWAHILI",label:"OCR_SWAHILI"},{type:"doc",id:"06-api-reference/variables/OCR_SWEDISH",label:"OCR_SWEDISH"},{type:"doc",id:"06-api-reference/variables/OCR_TABASSARAN",label:"OCR_TABASSARAN"},{type:"doc",id:"06-api-reference/variables/OCR_TAGALOG",label:"OCR_TAGALOG"},{type:"doc",id:"06-api-reference/variables/OCR_TAJIK",label:"OCR_TAJIK"},{type:"doc",id:"06-api-reference/variables/OCR_TELUGU",label:"OCR_TELUGU"},{type:"doc",id:"06-api-reference/variables/OCR_TURKISH",label:"OCR_TURKISH"},{type:"doc",id:"06-api-reference/variables/OCR_UKRAINIAN",label:"OCR_UKRAINIAN"},{type:"doc",id:"06-api-reference/variables/OCR_UZBEK",label:"OCR_UZBEK"},{type:"doc",id:"06-api-reference/variables/OCR_VIETNAMESE",label:"OCR_VIETNAMESE"},{type:"doc",id:"06-api-reference/variables/OCR_WELSH",label:"OCR_WELSH"}]},{type:"category",label:"Other",items:[{type:"doc",id:"06-api-reference/enumerations/RnExecutorchErrorCode",label:"RnExecutorchErrorCode"},{type:"doc",id:"06-api-reference/classes/Logger",label:"Logger"},{type:"doc",id:"06-api-reference/classes/RnExecutorchError",label:"RnExecutorchError"}]},{type:"category",label:"TTS Supported Voices",items:[{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_HEART",label:"KOKORO_VOICE_AF_HEART"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_RIVER",label:"KOKORO_VOICE_AF_RIVER"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AF_SARAH",label:"KOKORO_VOICE_AF_SARAH"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_ADAM",label:"KOKORO_VOICE_AM_ADAM"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_MICHAEL",label:"KOKORO_VOICE_AM_MICHAEL"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_AM_SANTA",label:"KOKORO_VOICE_AM_SANTA"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_BF_EMMA",label:"KOKORO_VOICE_BF_EMMA"},{type:"doc",id:"06-api-reference/variables/KOKORO_VOICE_BM_DANIEL",label:"KOKORO_VOICE_BM_DANIEL"}]},{type:"category",label:"Types",items:[{type:"doc",id:"06-api-reference/enumerations/CocoLabel",label:"CocoLabel"},{type:"doc",id:"06-api-reference/enumerations/DeeplabLabel",label:"DeeplabLabel"},{type:"doc",id:"06-api-reference/enumerations/DownloadStatus",label:"DownloadStatus"},{type:"doc",id:"06-api-reference/enumerations/HTTP_CODE",label:"HTTP_CODE"},{type:"doc",id:"06-api-reference/enumerations/ScalarType",label:"ScalarType"},{type:"doc",id:"06-api-reference/enumerations/SelfieSegmentationLabel",label:"SelfieSegmentationLabel"},{type:"doc",id:"06-api-reference/enumerations/SourceType",label:"SourceType"},{type:"doc",id:"06-api-reference/interfaces/Bbox",label:"Bbox"},{type:"doc",id:"06-api-reference/interfaces/ChatConfig",label:"ChatConfig"},{type:"doc",id:"06-api-reference/interfaces/ClassificationProps",label:"ClassificationProps"},{type:"doc",id:"06-api-reference/interfaces/ClassificationType",label:"ClassificationType"},{type:"doc",id:"06-api-reference/interfaces/ContextStrategy",label:"ContextStrategy"},{type:"doc",id:"06-api-reference/interfaces/DecodingOptions",label:"DecodingOptions"},{type:"doc",id:"06-api-reference/interfaces/Detection",label:"Detection"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchModuleProps",label:"ExecutorchModuleProps"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchModuleType",label:"ExecutorchModuleType"},{type:"doc",id:"06-api-reference/interfaces/GenerationConfig",label:"GenerationConfig"},{type:"doc",id:"06-api-reference/interfaces/ImageEmbeddingsProps",label:"ImageEmbeddingsProps"},{type:"doc",id:"06-api-reference/interfaces/ImageEmbeddingsType",label:"ImageEmbeddingsType"},{type:"doc",id:"06-api-reference/interfaces/KokoroConfig",label:"KokoroConfig"},{type:"doc",id:"06-api-reference/interfaces/KokoroVoiceExtras",label:"KokoroVoiceExtras"},{type:"doc",id:"06-api-reference/interfaces/LLMConfig",label:"LLMConfig"},{type:"doc",id:"06-api-reference/interfaces/LLMProps",label:"LLMProps"},{type:"doc",id:"06-api-reference/interfaces/LLMType",label:"LLMType"},{type:"doc",id:"06-api-reference/interfaces/Message",label:"Message"},{type:"doc",id:"06-api-reference/interfaces/ObjectDetectionProps",label:"ObjectDetectionProps"},{type:"doc",id:"06-api-reference/interfaces/ObjectDetectionType",label:"ObjectDetectionType"},{type:"doc",id:"06-api-reference/interfaces/OCRDetection",label:"OCRDetection"},{type:"doc",id:"06-api-reference/interfaces/OCRProps",label:"OCRProps"},{type:"doc",id:"06-api-reference/interfaces/OCRType",label:"OCRType"},{type:"doc",id:"06-api-reference/interfaces/Point",label:"Point"},{type:"doc",id:"06-api-reference/interfaces/Segment",label:"Segment"},{type:"doc",id:"06-api-reference/interfaces/SemanticSegmentationProps",label:"SemanticSegmentationProps"},{type:"doc",id:"06-api-reference/interfaces/SemanticSegmentationType",label:"SemanticSegmentationType"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextModelConfig",label:"SpeechToTextModelConfig"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextProps",label:"SpeechToTextProps"},{type:"doc",id:"06-api-reference/interfaces/SpeechToTextType",label:"SpeechToTextType"},{type:"doc",id:"06-api-reference/interfaces/StyleTransferProps",label:"StyleTransferProps"},{type:"doc",id:"06-api-reference/interfaces/StyleTransferType",label:"StyleTransferType"},{type:"doc",id:"06-api-reference/interfaces/TensorPtr",label:"TensorPtr"},{type:"doc",id:"06-api-reference/interfaces/TextEmbeddingsProps",label:"TextEmbeddingsProps"},{type:"doc",id:"06-api-reference/interfaces/TextEmbeddingsType",label:"TextEmbeddingsType"},{type:"doc",id:"06-api-reference/interfaces/TextToImageProps",label:"TextToImageProps"},{type:"doc",id:"06-api-reference/interfaces/TextToImageType",label:"TextToImageType"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechConfig",label:"TextToSpeechConfig"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechInput",label:"TextToSpeechInput"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechProps",label:"TextToSpeechProps"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechStreamingInput",label:"TextToSpeechStreamingInput"},{type:"doc",id:"06-api-reference/interfaces/TextToSpeechType",label:"TextToSpeechType"},{type:"doc",id:"06-api-reference/interfaces/TokenizerProps",label:"TokenizerProps"},{type:"doc",id:"06-api-reference/interfaces/TokenizerType",label:"TokenizerType"},{type:"doc",id:"06-api-reference/interfaces/ToolCall",label:"ToolCall"},{type:"doc",id:"06-api-reference/interfaces/ToolsConfig",label:"ToolsConfig"},{type:"doc",id:"06-api-reference/interfaces/TranscriptionResult",label:"TranscriptionResult"},{type:"doc",id:"06-api-reference/interfaces/TranscriptionSegment",label:"TranscriptionSegment"},{type:"doc",id:"06-api-reference/interfaces/VADProps",label:"VADProps"},{type:"doc",id:"06-api-reference/interfaces/VADType",label:"VADType"},{type:"doc",id:"06-api-reference/interfaces/VerticalOCRProps",label:"VerticalOCRProps"},{type:"doc",id:"06-api-reference/interfaces/VoiceConfig",label:"VoiceConfig"},{type:"doc",id:"06-api-reference/interfaces/Word",label:"Word"},{type:"doc",id:"06-api-reference/type-aliases/LabelEnum",label:"LabelEnum"},{type:"doc",id:"06-api-reference/type-aliases/LLMTool",label:"LLMTool"},{type:"doc",id:"06-api-reference/type-aliases/MessageRole",label:"MessageRole"},{type:"doc",id:"06-api-reference/type-aliases/ModelNameOf",label:"ModelNameOf"},{type:"doc",id:"06-api-reference/type-aliases/OCRLanguage",label:"OCRLanguage"},{type:"doc",id:"06-api-reference/type-aliases/ResourceSource",label:"ResourceSource"},{type:"doc",id:"06-api-reference/type-aliases/SegmentationLabels",label:"SegmentationLabels"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationConfig",label:"SemanticSegmentationConfig"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationModelName",label:"SemanticSegmentationModelName"},{type:"doc",id:"06-api-reference/type-aliases/SemanticSegmentationModelSources",label:"SemanticSegmentationModelSources"},{type:"doc",id:"06-api-reference/type-aliases/SpeechToTextLanguage",label:"SpeechToTextLanguage"},{type:"doc",id:"06-api-reference/type-aliases/TensorBuffer",label:"TensorBuffer"},{type:"doc",id:"06-api-reference/type-aliases/TextToSpeechLanguage",label:"TextToSpeechLanguage"},{type:"doc",id:"06-api-reference/type-aliases/Triple",label:"Triple"},{type:"doc",id:"06-api-reference/variables/SPECIAL_TOKENS",label:"SPECIAL_TOKENS"}]},{type:"category",label:"Typescript API",items:[{type:"doc",id:"06-api-reference/classes/ClassificationModule",label:"ClassificationModule"},{type:"doc",id:"06-api-reference/classes/ExecutorchModule",label:"ExecutorchModule"},{type:"doc",id:"06-api-reference/classes/ImageEmbeddingsModule",label:"ImageEmbeddingsModule"},{type:"doc",id:"06-api-reference/classes/LLMModule",label:"LLMModule"},{type:"doc",id:"06-api-reference/classes/ObjectDetectionModule",label:"ObjectDetectionModule"},{type:"doc",id:"06-api-reference/classes/OCRModule",label:"OCRModule"},{type:"doc",id:"06-api-reference/classes/SemanticSegmentationModule",label:"SemanticSegmentationModule"},{type:"doc",id:"06-api-reference/classes/SpeechToTextModule",label:"SpeechToTextModule"},{type:"doc",id:"06-api-reference/classes/StyleTransferModule",label:"StyleTransferModule"},{type:"doc",id:"06-api-reference/classes/TextEmbeddingsModule",label:"TextEmbeddingsModule"},{type:"doc",id:"06-api-reference/classes/TextToImageModule",label:"TextToImageModule"},{type:"doc",id:"06-api-reference/classes/TextToSpeechModule",label:"TextToSpeechModule"},{type:"doc",id:"06-api-reference/classes/TokenizerModule",label:"TokenizerModule"},{type:"doc",id:"06-api-reference/classes/VADModule",label:"VADModule"},{type:"doc",id:"06-api-reference/classes/VerticalOCRModule",label:"VerticalOCRModule"}]},{type:"category",label:"Utilities - General",items:[{type:"category",label:"ResourceFetcherUtils",items:[{type:"category",label:"Functions",items:[{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/calculateDownloadProgress",label:"calculateDownloadProgress"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/getFilenameFromUri",label:"getFilenameFromUri"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/hashObject",label:"hashObject"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/removeFilePrefix",label:"removeFilePrefix"},{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/functions/triggerHuggingFaceDownloadCounter",label:"triggerHuggingFaceDownloadCounter"}]}],link:{type:"doc",id:"06-api-reference/react-native-executorch/namespaces/ResourceFetcherUtils/index"}},{type:"doc",id:"06-api-reference/classes/ResourceFetcher",label:"ResourceFetcher"},{type:"doc",id:"06-api-reference/interfaces/ExecutorchConfig",label:"ExecutorchConfig"},{type:"doc",id:"06-api-reference/interfaces/ResourceFetcherAdapter",label:"ResourceFetcherAdapter"},{type:"doc",id:"06-api-reference/functions/cleanupExecutorch",label:"cleanupExecutorch"},{type:"doc",id:"06-api-reference/functions/initExecutorch",label:"initExecutorch"}]},{type:"category",label:"Utilities - LLM",items:[{type:"doc",id:"06-api-reference/variables/DEFAULT_CHAT_CONFIG",label:"DEFAULT_CHAT_CONFIG"},{type:"doc",id:"06-api-reference/variables/DEFAULT_CONTEXT_BUFFER_TOKENS",label:"DEFAULT_CONTEXT_BUFFER_TOKENS"},{type:"doc",id:"06-api-reference/variables/DEFAULT_MESSAGE_HISTORY",label:"DEFAULT_MESSAGE_HISTORY"},{type:"doc",id:"06-api-reference/variables/DEFAULT_SYSTEM_PROMPT",label:"DEFAULT_SYSTEM_PROMPT"},{type:"doc",id:"06-api-reference/variables/parseToolCall",label:"parseToolCall"},{type:"doc",id:"06-api-reference/functions/DEFAULT_STRUCTURED_OUTPUT_PROMPT",label:"DEFAULT_STRUCTURED_OUTPUT_PROMPT"},{type:"doc",id:"06-api-reference/functions/fixAndValidateStructuredOutput",label:"fixAndValidateStructuredOutput"},{type:"doc",id:"06-api-reference/functions/getStructuredOutputPrompt",label:"getStructuredOutputPrompt"}]},{type:"category",label:"Utils",items:[{type:"doc",id:"06-api-reference/classes/MessageCountContextStrategy",label:"MessageCountContextStrategy"},{type:"doc",id:"06-api-reference/classes/NoopContextStrategy",label:"NoopContextStrategy"},{type:"doc",id:"06-api-reference/classes/SlidingWindowContextStrategy",label:"SlidingWindowContextStrategy"}]}]}; module.exports = typedocSidebar.items; \ No newline at end of file diff --git a/packages/react-native-executorch/.gitignore b/packages/react-native-executorch/.gitignore index 696276e65..1734d456d 100644 --- a/packages/react-native-executorch/.gitignore +++ b/packages/react-native-executorch/.gitignore @@ -1,3 +1,6 @@ *.tsbuildinfo -third-party/ios/ExecutorchLib/output \ No newline at end of file +third-party/ios/ExecutorchLib/output + +# Test assets +common/rnexecutorch/tests/integration/assets/ \ No newline at end of file diff --git a/packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.cpp b/packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.cpp index 9d4b419e2..8d2c06148 100644 --- a/packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.cpp +++ b/packages/react-native-executorch/common/rnexecutorch/RnExecutorchInstaller.cpp @@ -1,10 +1,12 @@ #include "RnExecutorchInstaller.h" +#include #include #include #include #include #include +#include #include #include #include @@ -47,6 +49,12 @@ void RnExecutorchInstaller::injectJSIBindings( models::semantic_segmentation::BaseSemanticSegmentation>( jsiRuntime, jsCallInvoker, "loadSemanticSegmentation")); + jsiRuntime->global().setProperty( + *jsiRuntime, "loadInstanceSegmentation", + RnExecutorchInstaller::loadModel< + models::instance_segmentation::BaseInstanceSegmentation>( + jsiRuntime, jsCallInvoker, "loadInstanceSegmentation")); + jsiRuntime->global().setProperty( *jsiRuntime, "loadTextToImage", RnExecutorchInstaller::loadModel( diff --git a/packages/react-native-executorch/common/rnexecutorch/host_objects/JsiConversions.h b/packages/react-native-executorch/common/rnexecutorch/host_objects/JsiConversions.h index df9abbdef..6029a0385 100644 --- a/packages/react-native-executorch/common/rnexecutorch/host_objects/JsiConversions.h +++ b/packages/react-native-executorch/common/rnexecutorch/host_objects/JsiConversions.h @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -443,6 +444,46 @@ inline jsi::Value getJsiValue( return array; } +inline jsi::Value getJsiValue( + const std::vector + &instances, + jsi::Runtime &runtime) { + jsi::Array array(runtime, instances.size()); + for (std::size_t i = 0; i < instances.size(); ++i) { + jsi::Object instance(runtime); + + // Bbox + jsi::Object bbox(runtime); + bbox.setProperty(runtime, "x1", instances[i].x1); + bbox.setProperty(runtime, "y1", instances[i].y1); + bbox.setProperty(runtime, "x2", instances[i].x2); + bbox.setProperty(runtime, "y2", instances[i].y2); + instance.setProperty(runtime, "bbox", bbox); + + // Mask as Uint8Array + auto maskBuffer = std::make_shared( + instances[i].mask.data(), instances[i].mask.size()); + jsi::ArrayBuffer arrayBuffer(runtime, maskBuffer); + auto uint8ArrayCtor = + runtime.global().getPropertyAsFunction(runtime, "Uint8Array"); + auto uint8Array = uint8ArrayCtor.callAsConstructor(runtime, arrayBuffer) + .getObject(runtime); + instance.setProperty(runtime, "mask", uint8Array); + + instance.setProperty(runtime, "maskWidth", instances[i].maskWidth); + instance.setProperty(runtime, "maskHeight", instances[i].maskHeight); + + // Label - return as number, let TypeScript convert to string using labelMap + instance.setProperty(runtime, "label", instances[i].label); + + instance.setProperty(runtime, "score", instances[i].score); + instance.setProperty(runtime, "instanceId", instances[i].instanceId); + + array.setValueAtIndex(runtime, i, instance); + } + return array; +} + inline jsi::Value getJsiValue(const std::vector &detections, jsi::Runtime &runtime) { diff --git a/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp new file mode 100644 index 000000000..0480a2015 --- /dev/null +++ b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp @@ -0,0 +1,488 @@ +#include "BaseInstanceSegmentation.h" + +#include +#include +#include +#include +#include +namespace rnexecutorch::models::instance_segmentation { + +BaseInstanceSegmentation::BaseInstanceSegmentation( + const std::string &modelSource, const std::string &postprocessorType, + std::vector normMean, std::vector normStd, bool applyNMS, + std::shared_ptr callInvoker) + : BaseModel(modelSource, callInvoker), + postprocessorType_(postprocessorType), applyNMS_(applyNMS) { + // Store normalization parameters if provided + if (normMean.size() == 3) { + normMean_ = cv::Scalar(normMean[0], normMean[1], normMean[2]); + } + if (normStd.size() == 3) { + normStd_ = cv::Scalar(normStd[0], normStd[1], normStd[2]); + } + + // For multi-method models, we set a default size + modelImageSize = cv::Size(416, 416); +} + +float BaseInstanceSegmentation::intersectionOverUnion( + const types::InstanceMask &a, const types::InstanceMask &b) { + float x1 = std::max(a.x1, b.x1); + float y1 = std::max(a.y1, b.y1); + float x2 = std::min(a.x2, b.x2); + float y2 = std::min(a.y2, b.y2); + + float intersectionArea = std::max(0.0f, x2 - x1) * std::max(0.0f, y2 - y1); + float areaA = (a.x2 - a.x1) * (a.y2 - a.y1); + float areaB = (b.x2 - b.x1) * (b.y2 - b.y1); + float unionArea = areaA + areaB - intersectionArea; + + return (unionArea > 0) ? (intersectionArea / unionArea) : 0.0f; +} + +std::vector BaseInstanceSegmentation::nonMaxSuppression( + std::vector instances, double iouThreshold) { + if (instances.empty()) { + return {}; + } + + // Sort by score (descending) + std::sort(instances.begin(), instances.end(), + [](const types::InstanceMask &a, const types::InstanceMask &b) { + return a.score > b.score; + }); + + std::vector result; + std::vector suppressed(instances.size(), false); + + for (size_t i = 0; i < instances.size(); ++i) { + if (suppressed[i]) { + continue; + } + + result.push_back(instances[i]); + + for (size_t j = i + 1; j < instances.size(); ++j) { + if (suppressed[j]) { + continue; + } + + // Only suppress if same class + if (instances[i].label == instances[j].label) { + float iou = intersectionOverUnion(instances[i], instances[j]); + if (iou > iouThreshold) { + suppressed[j] = true; + } + } + } + } + + return result; +} + +std::vector BaseInstanceSegmentation::postprocess( + const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, double iouThreshold, + int maxInstances, const std::vector &classIndices, + bool returnMaskAtOriginalResolution) { + + // Validate parameters + if (confidenceThreshold <= 0 || confidenceThreshold > 1) { + throw RnExecutorchError(RnExecutorchErrorCode::InvalidConfig, + "Confidence threshold must be greater than 0 " + "and less than or equal to 1."); + } + + if (iouThreshold <= 0 || iouThreshold > 1) { + throw RnExecutorchError(RnExecutorchErrorCode::InvalidConfig, + "IoU threshold must be greater than 0 " + "and less than or equal to 1."); + } + + // Create allowed classes set for filtering + auto allowedClasses = createAllowedClassesSet(classIndices); + + // Delegate to model-specific postprocessing based on config + std::vector instances; + + if (postprocessorType_ == "rfdetr") { + instances = postprocessRFDetr(tensors, originalSize, modelInputSize, + confidenceThreshold, allowedClasses, + returnMaskAtOriginalResolution); + } else if (postprocessorType_ == "yolo") { + instances = postprocessYOLO(tensors, originalSize, modelInputSize, + confidenceThreshold, allowedClasses, + returnMaskAtOriginalResolution); + } else { + throw RnExecutorchError( + RnExecutorchErrorCode::InvalidConfig, + "Unknown postprocessor type: " + postprocessorType_ + + ". Expected 'yolo' or 'rfdetr'."); + } + + return finalizeInstances(instances, iouThreshold, maxInstances); +} + +// Helper: Create allowed classes set from vector +std::set BaseInstanceSegmentation::createAllowedClassesSet( + const std::vector &classIndices) { + if (classIndices.empty()) { + return {}; + } + return std::set(classIndices.begin(), classIndices.end()); +} + +// Helper: Apply sigmoid and threshold to convert logits to binary mask +std::vector +BaseInstanceSegmentation::applySigmoidAndThreshold(const float *logits, + int size) { + std::vector binaryMask(size); + for (int i = 0; i < size; ++i) { + float prob = 1.0f / (1.0f + std::exp(-logits[i])); + binaryMask[i] = (prob > 0.5f) ? 1 : 0; + } + return binaryMask; +} + +// RFDetr-specific postprocessing +std::vector BaseInstanceSegmentation::postprocessRFDetr( + const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, + const std::set &allowedClasses, + bool returnMaskAtOriginalResolution) { + + // Tensor 0: [1, N, 4] - Bounding boxes (cxcywh normalized) + // Tensor 1: [1, N, 91] - Class logits (pre-sigmoid) + // Tensor 2: [1, N, H, W] - Mask logits (pre-sigmoid) + + auto bboxTensor = tensors[0].toTensor(); + auto classLogitsTensor = tensors[1].toTensor(); + auto maskLogitsTensor = tensors[2].toTensor(); + + int numDetections = bboxTensor.size(1); + int numClasses = classLogitsTensor.size(2); + int maskHeight = maskLogitsTensor.size(2); + int maskWidth = maskLogitsTensor.size(3); + + const float *bboxData = + static_cast(bboxTensor.const_data_ptr()); + const float *classLogitsData = + static_cast(classLogitsTensor.const_data_ptr()); + const float *maskLogitsData = + static_cast(maskLogitsTensor.const_data_ptr()); + + float widthRatio = + static_cast(originalSize.width) / modelInputSize.width; + float heightRatio = + static_cast(originalSize.height) / modelInputSize.height; + + std::vector instances; + + for (int i = 0; i < numDetections; ++i) { + // Parse class logits and apply sigmoid to get probabilities + const float *logits = classLogitsData + (i * numClasses); + float maxScore = -std::numeric_limits::infinity(); + int maxClass = -1; + + for (int c = 0; c < numClasses; ++c) { + // Apply sigmoid: 1 / (1 + exp(-x)) + float prob = 1.0f / (1.0f + std::exp(-logits[c])); + if (prob > maxScore) { + maxScore = prob; + maxClass = c; + } + } + + // Skip if below confidence threshold + if (maxScore < confidenceThreshold) { + continue; + } + + // Filter by class if specified (use 1-indexed for COCO compatibility) + if (!allowedClasses.empty() && + allowedClasses.find(maxClass) == allowedClasses.end()) { + continue; + } + + // Parse bounding box (cxcywh normalized [0, 1]) + const float *bbox = bboxData + (i * 4); + float cx_norm = bbox[0]; + float cy_norm = bbox[1]; + float w_norm = bbox[2]; + float h_norm = bbox[3]; + + // Convert normalized cxcywh to absolute xyxy (scaled to model input size) + float cx = cx_norm * modelInputSize.width; + float cy = cy_norm * modelInputSize.height; + float w = w_norm * modelInputSize.width; + float h = h_norm * modelInputSize.height; + + float x1_model = cx - w / 2.0f; + float y1_model = cy - h / 2.0f; + float x2_model = cx + w / 2.0f; + float y2_model = cy + h / 2.0f; + + // Scale to original image size + float widthRatio = + static_cast(originalSize.width) / modelInputSize.width; + float heightRatio = + static_cast(originalSize.height) / modelInputSize.height; + + float x1 = x1_model * widthRatio; + float y1 = y1_model * heightRatio; + float x2 = x2_model * widthRatio; + float y2 = y2_model * heightRatio; + + // Apply sigmoid to mask logits and threshold + const float *maskLogits = maskLogitsData + (i * maskHeight * maskWidth); + std::vector binaryMask = + applySigmoidAndThreshold(maskLogits, maskHeight * maskWidth); + + // Resize and crop mask + int finalMaskWidth, finalMaskHeight; + std::vector finalMask = resizeAndCropMask( + binaryMask, maskWidth, maskHeight, originalSize, x1, y1, x2, y2, + returnMaskAtOriginalResolution, finalMaskWidth, finalMaskHeight); + + types::InstanceMask instance; + instance.x1 = x1; + instance.y1 = y1; + instance.x2 = x2; + instance.y2 = y2; + instance.mask = std::move(finalMask); + instance.maskWidth = finalMaskWidth; + instance.maskHeight = finalMaskHeight; + instance.label = maxClass; + instance.score = maxScore; + instance.instanceId = i; + + instances.push_back(std::move(instance)); + } + + return instances; +} + +// YOLO-specific postprocessing +std::vector BaseInstanceSegmentation::postprocessYOLO( + const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, + const std::set &allowedClasses, + bool returnMaskAtOriginalResolution) { + + // Tensor 0: [1, N, 38] - Detections (x1, y1, x2, y2, score, class, mask_coef + // x32) Tensor 1: [1, 32, H, W] - Prototype masks + + auto detectionTensor = tensors[0].toTensor(); + auto protoTensor = tensors[1].toTensor(); + + if (protoTensor.dim() != 4 || protoTensor.size(1) != 32) { + throw RnExecutorchError( + RnExecutorchErrorCode::UnexpectedNumInputs, + "Expected prototype mask tensor shape [1, 32, H, W]"); + } + + int numDetections = detectionTensor.size(1); + int protoHeight = protoTensor.size(2); + int protoWidth = protoTensor.size(3); + + const float *detectionData = + static_cast(detectionTensor.const_data_ptr()); + const float *protoData = + static_cast(protoTensor.const_data_ptr()); + + float widthRatio = + static_cast(originalSize.width) / modelInputSize.width; + float heightRatio = + static_cast(originalSize.height) / modelInputSize.height; + + std::vector instances; + + for (int i = 0; i < numDetections; ++i) { + // Each detection: [x1, y1, x2, y2, score, class, mask_coef_0...31] + const float *detection = detectionData + (i * 38); + + float x1 = detection[0]; + float y1 = detection[1]; + float x2 = detection[2]; + float y2 = detection[3]; + float score = detection[4]; + int label = static_cast(detection[5]); + + // Skip if below confidence threshold + if (score < confidenceThreshold) { + continue; + } + + // Filter by class if specified + if (!allowedClasses.empty() && + allowedClasses.find(label) == allowedClasses.end()) { + continue; + } + + // Extract mask coefficients (32 values starting at index 6) + std::vector maskCoefficients(32); + for (int j = 0; j < 32; j++) { + maskCoefficients[j] = detection[6 + j]; + } + + // Generate instance mask by multiplying coefficients with prototype masks + std::vector instanceMask(protoHeight * protoWidth, 0.0f); + + for (int maskIdx = 0; maskIdx < 32; maskIdx++) { + float coef = maskCoefficients[maskIdx]; + const float *protoMask = protoData + (maskIdx * protoHeight * protoWidth); + + for (int pixelIdx = 0; pixelIdx < protoHeight * protoWidth; pixelIdx++) { + instanceMask[pixelIdx] += coef * protoMask[pixelIdx]; + } + } + + // Apply sigmoid and threshold + std::vector binaryMask = + applySigmoidAndThreshold(instanceMask.data(), protoHeight * protoWidth); + + // Scale bounding box to original image size + x1 *= widthRatio; + y1 *= heightRatio; + x2 *= widthRatio; + y2 *= heightRatio; + + // Resize and crop mask + int finalMaskWidth, finalMaskHeight; + std::vector finalMask = resizeAndCropMask( + binaryMask, protoWidth, protoHeight, originalSize, x1, y1, x2, y2, + returnMaskAtOriginalResolution, finalMaskWidth, finalMaskHeight); + + types::InstanceMask instance; + instance.x1 = x1; + instance.y1 = y1; + instance.x2 = x2; + instance.y2 = y2; + instance.mask = std::move(finalMask); + instance.maskWidth = finalMaskWidth; + instance.maskHeight = finalMaskHeight; + instance.label = label; + instance.score = score; + instance.instanceId = i; + + instances.push_back(std::move(instance)); + } + + return instances; +} + +// Helper function: Resize mask to original resolution and crop to bounding box +std::vector BaseInstanceSegmentation::resizeAndCropMask( + const std::vector &mask, int maskWidth, int maskHeight, + cv::Size originalSize, float x1, float y1, float x2, float y2, + bool returnAtOriginalResolution, int &outWidth, int &outHeight) { + + if (!returnAtOriginalResolution) { + outWidth = maskWidth; + outHeight = maskHeight; + return mask; + } + + // Resize mask to original image size + cv::Mat maskMat(maskHeight, maskWidth, CV_8UC1, + const_cast(mask.data())); + cv::Mat resizedMaskMat; + cv::resize(maskMat, resizedMaskMat, originalSize, 0, 0, cv::INTER_NEAREST); + + outWidth = originalSize.width; + outHeight = originalSize.height; + + // Crop mask to bounding box (zero out pixels outside bbox) + for (int y = 0; y < outHeight; y++) { + for (int x = 0; x < outWidth; x++) { + int idx = y * outWidth + x; + if (x < x1 || x > x2 || y < y1 || y > y2) { + resizedMaskMat.data[idx] = 0; + } + } + } + + std::vector result(resizedMaskMat.data, + resizedMaskMat.data + resizedMaskMat.total()); + return result; +} + +// Helper function: Apply NMS, limit instances, and renumber IDs +std::vector BaseInstanceSegmentation::finalizeInstances( + std::vector instances, double iouThreshold, + int maxInstances) { + + // Apply NMS if enabled + if (applyNMS_) { + instances = nonMaxSuppression(instances, iouThreshold); + } + + // Limit to maxInstances + if (instances.size() > static_cast(maxInstances)) { + instances.resize(maxInstances); + } + + // Renumber instance IDs to be sequential + for (size_t i = 0; i < instances.size(); ++i) { + instances[i].instanceId = static_cast(i); + } + + return instances; +} + +std::vector BaseInstanceSegmentation::generate( + std::string imageSource, double confidenceThreshold, double iouThreshold, + int maxInstances, std::vector classIndices, + bool returnMaskAtOriginalResolution, int32_t inputSize) { + + std::string methodName; + cv::Size modelInputSize; + std::vector inputShape; + + if (inputSize == 0) { + // Single-method model: use 'forward' and auto-detect input shape + methodName = "forward"; + + // Get input shape from model metadata + auto inputShapeVec = getInputShape(methodName, 0); + if (inputShapeVec.size() != 4) { + throw RnExecutorchError( + RnExecutorchErrorCode::UnexpectedNumInputs, + "Expected 4D input tensor [batch, channels, height, width], got " + + std::to_string(inputShapeVec.size()) + "D"); + } + + int32_t height = inputShapeVec[2]; + int32_t width = inputShapeVec[3]; + modelInputSize = cv::Size(width, height); + inputShape = {1, 3, height, width}; + + } else { + // Multi-method model: use 'forward_{size}' + methodName = getMethodName(inputSize); + modelInputSize = cv::Size(inputSize, inputSize); + inputShape = {1, 3, inputSize, inputSize}; + } + + // Read and preprocess image with optional normalization + // readImageToTensor will apply normalization if normMean_ and normStd_ are + // provided + auto [inputTensor, originalSize] = image_processing::readImageToTensor( + imageSource, inputShape, false, normMean_, normStd_); + + // Execute model + auto forwardResult = BaseModel::execute(methodName, {inputTensor}); + if (!forwardResult.ok()) { + throw RnExecutorchError( + forwardResult.error(), + "The model's forward function did not succeed. " + "Ensure the model input is correct and method name '" + + methodName + "' is valid."); + } + + return postprocess(forwardResult.get(), originalSize, modelInputSize, + confidenceThreshold, iouThreshold, maxInstances, + classIndices, returnMaskAtOriginalResolution); +} + +} // namespace rnexecutorch::models::instance_segmentation diff --git a/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.h b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.h new file mode 100644 index 000000000..24829bbc4 --- /dev/null +++ b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.h @@ -0,0 +1,95 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include "Types.h" +#include "rnexecutorch/metaprogramming/ConstructorHelpers.h" +#include + +namespace rnexecutorch { +namespace models::instance_segmentation { +using executorch::extension::TensorPtr; +using executorch::runtime::EValue; + +class BaseInstanceSegmentation : public BaseModel { +public: + BaseInstanceSegmentation(const std::string &modelSource, + const std::string &postprocessorType, + std::vector normMean, + std::vector normStd, bool applyNMS, + std::shared_ptr callInvoker); + + [[nodiscard("Registered non-void function")]] std::vector + generate(std::string imageSource, double confidenceThreshold, + double iouThreshold, int maxInstances, + std::vector classIndices, + bool returnMaskAtOriginalResolution, int32_t inputSize); + +private: + std::vector + postprocess(const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, + double iouThreshold, int maxInstances, + const std::vector &classIndices, + bool returnMaskAtOriginalResolution); + + std::vector + postprocessRFDetr(const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, + const std::set &allowedClasses, + bool returnMaskAtOriginalResolution); + + std::vector + postprocessYOLO(const std::vector &tensors, cv::Size originalSize, + cv::Size modelInputSize, double confidenceThreshold, + const std::set &allowedClasses, + bool returnMaskAtOriginalResolution); + + std::set + createAllowedClassesSet(const std::vector &classIndices); + + std::vector applySigmoidAndThreshold(const float *logits, int size); + + float intersectionOverUnion(const types::InstanceMask &a, + const types::InstanceMask &b); + + std::vector + nonMaxSuppression(std::vector instances, + double iouThreshold); + + std::vector resizeAndCropMask(const std::vector &mask, + int maskWidth, int maskHeight, + cv::Size originalSize, float x1, + float y1, float x2, float y2, + bool returnAtOriginalResolution, + int &outWidth, int &outHeight); + + std::vector + finalizeInstances(std::vector instances, + double iouThreshold, int maxInstances); + + std::string getMethodName(int32_t inputSize) const { + if (inputSize == 0) { + return "forward"; // Single-method model + } + return "forward_" + std::to_string(inputSize); // Multi-method model + } + + // Member variables + std::string postprocessorType_; + std::optional normMean_; + std::optional normStd_; + bool applyNMS_; + cv::Size modelImageSize{0, 0}; +}; +} // namespace models::instance_segmentation + +REGISTER_CONSTRUCTOR(models::instance_segmentation::BaseInstanceSegmentation, + std::string, std::string, std::vector, + std::vector, bool, + std::shared_ptr); +} // namespace rnexecutorch diff --git a/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/Types.h b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/Types.h new file mode 100644 index 000000000..dcda34c26 --- /dev/null +++ b/packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/Types.h @@ -0,0 +1,26 @@ +#pragma once + +#include + +namespace rnexecutorch::models::instance_segmentation::types { + +/** + * Represents a single detected instance in instance segmentation output. + * + * Contains bounding box coordinates, binary segmentation mask, class label, + * confidence score, and a unique instance identifier. + */ +struct InstanceMask { + float x1; ///< Bounding box left coordinate + float y1; ///< Bounding box top coordinate + float x2; ///< Bounding box right coordinate + float y2; ///< Bounding box bottom coordinate + std::vector mask; ///< Binary mask (0 or 1) for the instance + int maskWidth; ///< Width of the mask array + int maskHeight; ///< Height of the mask array + int label; ///< Class label index + float score; ///< Confidence score [0, 1] + int instanceId; ///< Unique identifier for this instance +}; + +} // namespace rnexecutorch::models::instance_segmentation::types diff --git a/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/test_audio_float.raw b/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/test_audio_float.raw deleted file mode 100644 index 177c7b891..000000000 Binary files a/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/test_audio_float.raw and /dev/null differ diff --git a/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/we_are_software_mansion.jpg b/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/we_are_software_mansion.jpg deleted file mode 100644 index 521416d00..000000000 Binary files a/packages/react-native-executorch/common/rnexecutorch/tests/integration/assets/we_are_software_mansion.jpg and /dev/null differ diff --git a/packages/react-native-executorch/common/rnexecutorch/tests/log.txt b/packages/react-native-executorch/common/rnexecutorch/tests/log.txt new file mode 100644 index 000000000..281adbf68 --- /dev/null +++ b/packages/react-native-executorch/common/rnexecutorch/tests/log.txt @@ -0,0 +1 @@ +Error: libc++_shared.so not found at: /toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so diff --git a/packages/react-native-executorch/src/constants/modelUrls.ts b/packages/react-native-executorch/src/constants/modelUrls.ts index 499abf63a..2e643c0b2 100644 --- a/packages/react-native-executorch/src/constants/modelUrls.ts +++ b/packages/react-native-executorch/src/constants/modelUrls.ts @@ -657,6 +657,55 @@ export const SELFIE_SEGMENTATION = { modelSource: SELFIE_SEGMENTATION_MODEL, } as const; +/** + * @category Models - Instance Segmentation + */ +const YOLO26N_SEG_MODEL = `${URL_PREFIX}-yolo26-seg/${NEXT_VERSION_TAG}/yolo26n-seg/xnnpack/yolo26n-seg.pte`; +const YOLO26S_SEG_MODEL = `${URL_PREFIX}-yolo26-seg/${NEXT_VERSION_TAG}/yolo26s-seg/xnnpack/yolo26s-seg.pte`; +const YOLO26M_SEG_MODEL = `${URL_PREFIX}-yolo26-seg/${NEXT_VERSION_TAG}/yolo26m-seg/xnnpack/yolo26m-seg.pte`; +const YOLO26L_SEG_MODEL = `${URL_PREFIX}-yolo26-seg/${NEXT_VERSION_TAG}/yolo26l-seg/xnnpack/yolo26l-seg.pte`; +const YOLO26X_SEG_MODEL = `${URL_PREFIX}-yolo26-seg/${NEXT_VERSION_TAG}/yolo26x-seg/xnnpack/yolo26x-seg.pte`; + +/** + * @category Models - Instance Segmentation + */ +export const YOLO26N_SEG = { + modelName: 'yolo26n-seg', + modelSource: YOLO26N_SEG_MODEL, +} as const; + +/** + * @category Models - Instance Segmentation + */ +export const YOLO26S_SEG = { + modelName: 'yolo26s-seg', + modelSource: YOLO26S_SEG_MODEL, +} as const; + +/** + * @category Models - Instance Segmentation + */ +export const YOLO26M_SEG = { + modelName: 'yolo26m-seg', + modelSource: YOLO26M_SEG_MODEL, +} as const; + +/** + * @category Models - Instance Segmentation + */ +export const YOLO26L_SEG = { + modelName: 'yolo26l-seg', + modelSource: YOLO26L_SEG_MODEL, +} as const; + +/** + * @category Models - Instance Segmentation + */ +export const YOLO26X_SEG = { + modelName: 'yolo26x-seg', + modelSource: YOLO26X_SEG_MODEL, +} as const; + // Image Embeddings const CLIP_VIT_BASE_PATCH32_IMAGE_MODEL = `${URL_PREFIX}-clip-vit-base-patch32/${VERSION_TAG}/clip-vit-base-patch32-vision_xnnpack.pte`; diff --git a/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts b/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts new file mode 100644 index 000000000..ab1e7d51f --- /dev/null +++ b/packages/react-native-executorch/src/hooks/computer_vision/useInstanceSegmentation.ts @@ -0,0 +1,138 @@ +import { useState, useEffect } from 'react'; +import { + InstanceSegmentationModule, + InstanceSegmentationLabels, +} from '../../modules/computer_vision/InstanceSegmentationModule'; +import { + InstanceSegmentationProps, + InstanceSegmentationType, + InstanceModelNameOf, + InstanceSegmentationModelSources, + InstanceSegmentationOptions, +} from '../../types/instanceSegmentation'; +import { RnExecutorchErrorCode } from '../../errors/ErrorCodes'; +import { RnExecutorchError, parseUnknownError } from '../../errors/errorUtils'; + +/** + * React hook for managing an Instance Segmentation model instance. + * + * Provides type-safe access to instance segmentation models with automatic label inference. + * For YOLO models, labels are automatically typed as COCO dataset classes (80 categories). + * + * @typeParam C - A {@link InstanceSegmentationModelSources} config specifying which model to load. + * @param props - Configuration object containing `model` config and optional `preventLoad` flag. + * @returns An object with model state (`error`, `isReady`, `isGenerating`, `downloadProgress`) and a typed `forward` function where result labels are type-safe. + * + * @example + * Using a pre-configured model constant: + * ```ts + * import { useInstanceSegmentation, YOLO26N_SEG } from 'react-native-executorch'; + * + * const { isReady, isGenerating, forward, error, downloadProgress } = + * useInstanceSegmentation({ model: YOLO26N_SEG }); + * + * if (!isReady) { + * return Loading: {(downloadProgress * 100).toFixed(0)}%; + * } + * + * const instances = await forward('path/to/image.jpg', { + * confidenceThreshold: 0.5, + * inputSize: 640, + * }); + * + * // instances[0].label is typed as COCO labels: "PERSON" | "CAR" | "DOG" | ... + * console.log(instances[0].label); // TypeScript knows all possible values + * ``` + * + * @category Hooks + */ +export const useInstanceSegmentation = < + C extends InstanceSegmentationModelSources, +>({ + model, + preventLoad = false, +}: InstanceSegmentationProps): InstanceSegmentationType< + InstanceSegmentationLabels> +> => { + const [error, setError] = useState(null); + const [isReady, setIsReady] = useState(false); + const [isGenerating, setIsGenerating] = useState(false); + const [downloadProgress, setDownloadProgress] = useState(0); + const [instance, setInstance] = useState + > | null>(null); + + useEffect(() => { + if (preventLoad) return; + + let isMounted = true; + let currentInstance: InstanceSegmentationModule< + InstanceModelNameOf + > | null = null; + + (async () => { + setDownloadProgress(0); + setError(null); + setIsReady(false); + try { + currentInstance = await InstanceSegmentationModule.fromModelName( + model, + (progress) => { + if (isMounted) setDownloadProgress(progress); + } + ); + if (isMounted) { + setInstance(currentInstance); + setIsReady(true); + } + } catch (err) { + if (isMounted) setError(parseUnknownError(err)); + } + })(); + + return () => { + isMounted = false; + currentInstance?.delete(); + }; + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [model.modelName, model.modelSource, preventLoad]); + + const forward = async ( + imageSource: string, + options?: InstanceSegmentationOptions< + InstanceSegmentationLabels> + > + ) => { + if (!isReady || !instance) { + throw new RnExecutorchError( + RnExecutorchErrorCode.ModuleNotLoaded, + 'The model is currently not loaded. Please load the model before calling forward().' + ); + } + if (isGenerating) { + throw new RnExecutorchError( + RnExecutorchErrorCode.ModelGenerating, + 'The model is currently generating. Please wait until previous model run is complete.' + ); + } + try { + setIsGenerating(true); + const result = await instance.forward(imageSource, options); + return result as any; + } catch (err) { + setError(parseUnknownError(err)); + throw err; + } finally { + setIsGenerating(false); + } + }; + + return { + error, + isReady, + isGenerating, + downloadProgress, + forward, + }; +}; diff --git a/packages/react-native-executorch/src/index.ts b/packages/react-native-executorch/src/index.ts index dd7557ca2..c984ca572 100644 --- a/packages/react-native-executorch/src/index.ts +++ b/packages/react-native-executorch/src/index.ts @@ -41,6 +41,13 @@ declare global { normMean: Triple | [], normStd: Triple | [] ) => any; + var loadInstanceSegmentation: ( + source: string, + postprocessorType: string, + normMean: number[] | [], + normStd: number[] | [], + applyNMS: boolean + ) => any; var loadClassification: (source: string) => any; var loadObjectDetection: (source: string) => any; var loadExecutorchModule: (source: string) => any; @@ -85,9 +92,11 @@ declare global { ) => any; } // eslint-disable no-var + if ( global.loadStyleTransfer == null || global.loadSemanticSegmentation == null || + global.loadInstanceSegmentation == null || global.loadTextToImage == null || global.loadExecutorchModule == null || global.loadClassification == null || @@ -115,6 +124,7 @@ export * from './hooks/computer_vision/useClassification'; export * from './hooks/computer_vision/useObjectDetection'; export * from './hooks/computer_vision/useStyleTransfer'; export * from './hooks/computer_vision/useSemanticSegmentation'; +export * from './hooks/computer_vision/useInstanceSegmentation'; export * from './hooks/computer_vision/useOCR'; export * from './hooks/computer_vision/useVerticalOCR'; export * from './hooks/computer_vision/useImageEmbeddings'; @@ -134,6 +144,7 @@ export * from './modules/computer_vision/ClassificationModule'; export * from './modules/computer_vision/ObjectDetectionModule'; export * from './modules/computer_vision/StyleTransferModule'; export * from './modules/computer_vision/SemanticSegmentationModule'; +export * from './modules/computer_vision/InstanceSegmentationModule'; export * from './modules/computer_vision/OCRModule'; export * from './modules/computer_vision/VerticalOCRModule'; export * from './modules/computer_vision/ImageEmbeddingsModule'; @@ -159,6 +170,7 @@ export * from './utils/llms/context_strategy'; export * from './types/objectDetection'; export * from './types/ocr'; export * from './types/semanticSegmentation'; +export * from './types/instanceSegmentation'; export * from './types/llm'; export * from './types/vad'; export * from './types/common'; diff --git a/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts b/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts new file mode 100644 index 000000000..3183507f5 --- /dev/null +++ b/packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts @@ -0,0 +1,353 @@ +import { ResourceFetcher } from '../../utils/ResourceFetcher'; +import { ResourceSource, LabelEnum } from '../../types/common'; +import { + InstanceSegmentationModelSources, + InstanceSegmentationConfig, + InstanceSegmentationModelName, + InstanceModelNameOf, + SegmentedInstance, + InstanceSegmentationOptions, +} from '../../types/instanceSegmentation'; +import { CocoLabel } from '../../types/objectDetection'; +import { RnExecutorchErrorCode } from '../../errors/ErrorCodes'; +import { RnExecutorchError } from '../../errors/errorUtils'; +import { BaseModule } from '../BaseModule'; + +/** + * Configuration for YOLO instance segmentation models. + * @category Configuration + */ +export const YOLO_SEG_CONFIG: InstanceSegmentationConfig = { + labelMap: CocoLabel, + availableInputSizes: [384, 416, 512, 640, 1024] as const, + defaultInputSize: 416, + postprocessorConfig: { + type: 'yolo', + defaultConfidenceThreshold: 0.5, + defaultIouThreshold: 0.5, + applyNMS: false, // YOLO already applies NMS internally + }, +}; + +const ModelConfigs = { + 'yolo26n-seg': YOLO_SEG_CONFIG, + 'yolo26s-seg': YOLO_SEG_CONFIG, + 'yolo26m-seg': YOLO_SEG_CONFIG, + 'yolo26l-seg': YOLO_SEG_CONFIG, + 'yolo26x-seg': YOLO_SEG_CONFIG, +} as const satisfies Record< + InstanceSegmentationModelName, + InstanceSegmentationConfig +>; + +/** @internal */ +type ModelConfigsType = typeof ModelConfigs; + +/** + * Resolves the {@link LabelEnum} for a given built-in model name. + * + * @typeParam M - A built-in model name from {@link InstanceSegmentationModelName}. + * + * @category Types + */ +export type InstanceSegmentationLabels< + M extends InstanceSegmentationModelName, +> = ModelConfigsType[M]['labelMap']; + +/** + * @internal + * Resolves the label type: if `T` is a {@link InstanceSegmentationModelName}, looks up its labels + * from the built-in config; otherwise uses `T` directly as a {@link LabelEnum}. + */ +type ResolveLabels = + T extends InstanceSegmentationModelName ? InstanceSegmentationLabels : T; + +/** + * Generic instance segmentation module with type-safe label maps. + * Use a model name (e.g. `'yolo26n-seg'`) as the generic parameter for pre-configured models, + * or a custom label enum for custom configs. + * + * Supported models (download from HuggingFace): + * - `yolo26n-seg`, `yolo26s-seg`, `yolo26m-seg`, `yolo26l-seg`, `yolo26x-seg` - YOLO models with COCO labels (80 classes) + * + * @typeParam T - Either a pre-configured model name from {@link InstanceSegmentationModelName} + * or a custom {@link LabelEnum} label map. + * + * @category Typescript API + * + * @example + * ```ts + * const segmentation = await InstanceSegmentationModule.fromModelName({ + * modelName: 'yolo26n-seg', + * modelSource: 'https://huggingface.co/.../yolo26n-seg.pte', + * }); + * + * const results = await segmentation.forward('path/to/image.jpg', { + * confidenceThreshold: 0.5, + * iouThreshold: 0.45, + * maxInstances: 20, + * inputSize: 640, + * }); + * ``` + */ +export class InstanceSegmentationModule< + T extends InstanceSegmentationModelName | LabelEnum, +> extends BaseModule { + private labelMap: ResolveLabels; + private modelConfig: InstanceSegmentationConfig; + + private constructor( + labelMap: ResolveLabels, + modelConfig: InstanceSegmentationConfig, + nativeModule: unknown + ) { + super(); + this.labelMap = labelMap; + this.modelConfig = modelConfig; + this.nativeModule = nativeModule; + } + + // TODO: figure it out so we can delete this (we need this because of basemodule inheritance) + override async load() {} + + /** + * Creates an instance segmentation module for a pre-configured model. + * The config object is discriminated by `modelName` — each model can require different fields. + * + * @param config - A {@link InstanceSegmentationModelSources} object specifying which model to load and where to fetch it from. + * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. + * @returns A Promise resolving to an `InstanceSegmentationModule` instance typed to the chosen model's label map. + * + * @example + * ```ts + * const segmentation = await InstanceSegmentationModule.fromModelName({ + * modelName: 'yolo26n-seg', + * modelSource: 'https://huggingface.co/.../yolo26n-seg.pte', + * }); + * ``` + */ + static async fromModelName( + config: C, + onDownloadProgress: (progress: number) => void = () => {} + ): Promise>> { + const { modelName, modelSource } = config; + const modelConfig = ModelConfigs[modelName as keyof typeof ModelConfigs]; + + const paths = await ResourceFetcher.fetch(onDownloadProgress, modelSource); + if (!paths?.[0]) { + throw new RnExecutorchError( + RnExecutorchErrorCode.DownloadInterrupted, + 'The download has been interrupted. As a result, not every file was downloaded. Please retry the download.' + ); + } + + if (typeof global.loadInstanceSegmentation !== 'function') { + throw new RnExecutorchError( + RnExecutorchErrorCode.ModuleNotLoaded, + `global.loadInstanceSegmentation is not available` + ); + } + + // Pass config parameters to native module + const nativeModule = global.loadInstanceSegmentation( + paths[0], + modelConfig.postprocessorConfig.type, + modelConfig.preprocessorConfig?.normMean || [], + modelConfig.preprocessorConfig?.normStd || [], + modelConfig.postprocessorConfig.applyNMS ?? true + ); + + return new InstanceSegmentationModule>( + modelConfig.labelMap as ResolveLabels>, + modelConfig, + nativeModule + ); + } + + /** + * Creates an instance segmentation module with a user-provided label map and custom config. + * Use this when working with a custom-exported segmentation model that is not one of the pre-configured models. + * + * @param modelSource - A fetchable resource pointing to the model binary. + * @param config - A {@link InstanceSegmentationConfig} object with the label map and optional preprocessing parameters. + * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1. + * @returns A Promise resolving to an `InstanceSegmentationModule` instance typed to the provided label map. + * + * @example + * ```ts + * const MyLabels = { PERSON: 0, CAR: 1 } as const; + * const segmentation = await InstanceSegmentationModule.fromCustomConfig( + * 'https://huggingface.co/.../custom_model.pte', + * { + * labelMap: MyLabels, + * availableInputSizes: [640], + * defaultInputSize: 640, + * postprocessorConfig: { + * type: 'yolo', + * defaultConfidenceThreshold: 0.5, + * defaultIouThreshold: 0.45, + * applyNMS: true, + * }, + * }, + * ); + * ``` + */ + static async fromCustomConfig( + modelSource: ResourceSource, + config: InstanceSegmentationConfig, + onDownloadProgress: (progress: number) => void = () => {} + ): Promise> { + const paths = await ResourceFetcher.fetch(onDownloadProgress, modelSource); + if (!paths?.[0]) { + throw new RnExecutorchError( + RnExecutorchErrorCode.DownloadInterrupted, + 'The download has been interrupted. Please retry.' + ); + } + + if (typeof global.loadInstanceSegmentation !== 'function') { + throw new RnExecutorchError( + RnExecutorchErrorCode.ModuleNotLoaded, + `global.loadInstanceSegmentation is not available` + ); + } + + // Pass config parameters to native module + const nativeModule = global.loadInstanceSegmentation( + paths[0], + config.postprocessorConfig.type, + config.preprocessorConfig?.normMean || [], + config.preprocessorConfig?.normStd || [], + config.postprocessorConfig.applyNMS ?? true + ); + + return new InstanceSegmentationModule( + config.labelMap as ResolveLabels, + config, + nativeModule + ); + } + + /** + * Executes the model's forward pass to perform instance segmentation on the provided image. + * + * @param imageSource - A string representing the image source (e.g., a file path, URI, or Base64-encoded string). + * @param options - Optional configuration for the segmentation process. Includes `confidenceThreshold`, `iouThreshold`, `maxInstances`, `classesOfInterest`, `returnMaskAtOriginalResolution`, and `inputSize`. + * @returns A Promise resolving to an array of {@link SegmentedInstance} objects with `bbox`, `mask`, `maskWidth`, `maskHeight`, `label`, `score`, and `instanceId`. + * @throws {RnExecutorchError} If the model is not loaded or if an invalid `inputSize` is provided. + * + * @example + * ```ts + * const results = await segmentation.forward('path/to/image.jpg', { + * confidenceThreshold: 0.6, + * iouThreshold: 0.5, + * maxInstances: 10, + * inputSize: 640, + * classesOfInterest: ['PERSON', 'CAR'], + * returnMaskAtOriginalResolution: true, + * }); + * + * results.forEach((inst) => { + * console.log(`${inst.label}: ${(inst.score * 100).toFixed(1)}%`); + * }); + * ``` + */ + async forward( + imageSource: string, + options?: InstanceSegmentationOptions> + ): Promise>[]> { + if (this.nativeModule == null) { + throw new RnExecutorchError( + RnExecutorchErrorCode.ModuleNotLoaded, + 'The model is currently not loaded.' + ); + } + + // Extract options with defaults from config + const confidenceThreshold = + options?.confidenceThreshold ?? + this.modelConfig.postprocessorConfig.defaultConfidenceThreshold ?? + 0.55; + const iouThreshold = + options?.iouThreshold ?? + this.modelConfig.postprocessorConfig.defaultIouThreshold ?? + 0.55; + const maxInstances = options?.maxInstances ?? 100; + const returnMaskAtOriginalResolution = + options?.returnMaskAtOriginalResolution ?? true; + + // Determine inputSize based on config + let inputSize: number; + + if ( + this.modelConfig.availableInputSizes && + this.modelConfig.defaultInputSize + ) { + // Multi-method model: validate against available sizes + inputSize = options?.inputSize ?? this.modelConfig.defaultInputSize; + + if (!this.modelConfig.availableInputSizes.includes(inputSize)) { + throw new RnExecutorchError( + RnExecutorchErrorCode.InvalidArgument, + `Invalid inputSize: ${inputSize}. Available sizes: ${this.modelConfig.availableInputSizes.join(', ')}` + ); + } + } else { + // Single-method model: use 0 to signal C++ to use 'forward' method + inputSize = 0; + + if (options?.inputSize !== undefined) { + console.warn( + '[Instance Segmentation] inputSize parameter ignored - model config does not specify availableInputSizes' + ); + } + } + + // Convert classesOfInterest labels to indices + const classIndices = options?.classesOfInterest + ? options.classesOfInterest.map((label) => { + const labelStr = String(label); + const index = this.labelMap[labelStr as keyof ResolveLabels]; + return typeof index === 'number' ? index : -1; + }) + : []; + + // Measure inference time + const startTime = performance.now(); + const nativeResult = await this.nativeModule.generate( + imageSource, + confidenceThreshold, + iouThreshold, + maxInstances, + classIndices, + returnMaskAtOriginalResolution, + inputSize // Pass inputSize as number instead of methodName as string + ); + const endTime = performance.now(); + const inferenceTime = endTime - startTime; + + const sizeStr = inputSize > 0 ? `${inputSize}x${inputSize}` : 'auto'; + console.log( + `[Instance Segmentation] Inference completed in ${inferenceTime.toFixed(2)}ms | Input size: ${sizeStr} | Detected: ${nativeResult.length} instances` + ); + + // Convert label indices back to label names + // YOLO outputs 0-indexed class IDs, but COCO labels are 1-indexed, so add 1 + const reverseLabelMap = Object.entries( + this.labelMap as Record + ).reduce( + (acc, [key, value]) => { + acc[value as number] = key as keyof ResolveLabels; + return acc; + }, + {} as Record> + ); + + return nativeResult.map((instance: any) => ({ + ...instance, + label: + reverseLabelMap[instance.label + 1] || + (`UNKNOWN_${instance.label}` as keyof ResolveLabels), + })) as SegmentedInstance>[]; + } +} diff --git a/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts b/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts index b3b7030b3..48c928b01 100644 --- a/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts +++ b/packages/react-native-executorch/src/modules/computer_vision/SemanticSegmentationModule.ts @@ -65,7 +65,7 @@ type ResolveLabels = /** * Generic semantic segmentation module with type-safe label maps. - * Use a model name (e.g. `'deeplab-v3-resnet50'`) as the generic parameter for built-in models, + * Use a model name (e.g. `'deeplab-v3'`) as the generic parameter for built-in models, * or a custom label enum for custom configs. * * @typeParam T - Either a built-in model name (`'deeplab-v3-resnet50'`, diff --git a/packages/react-native-executorch/src/types/instanceSegmentation.ts b/packages/react-native-executorch/src/types/instanceSegmentation.ts new file mode 100644 index 000000000..eacca893a --- /dev/null +++ b/packages/react-native-executorch/src/types/instanceSegmentation.ts @@ -0,0 +1,252 @@ +import { RnExecutorchError } from '../errors/errorUtils'; +import { LabelEnum, ResourceSource } from './common'; +import { Bbox } from './objectDetection'; + +/** + * Represents a single detected instance in instance segmentation output. + * + * @typeParam L - The {@link LabelEnum} type for the model. + * @category Types + * @property {Bbox} bbox - The bounding box of the instance. + * @property {Uint8Array} mask - Binary mask (0 or 1) representing the instance. + * @property {number} maskWidth - Width of the mask array. + * @property {number} maskHeight - Height of the mask array. + * @property {keyof L} label - The class label of the instance. + * @property {number} score - Confidence score [0, 1]. + * @property {number} instanceId - Unique identifier for this instance. + */ +export interface SegmentedInstance { + bbox: Bbox; + mask: Uint8Array; + maskWidth: number; + maskHeight: number; + label: keyof L; + score: number; + instanceId: number; +} + +/** + * Preprocessor configuration for instance segmentation models. + * + * @category Types + */ +export interface PreprocessorConfig { + /** + * Mean values for normalization [R, G, B]. Applied as: (pixel / 255.0 - mean) / std + */ + normMean?: [number, number, number]; + /** + * Standard deviation values for normalization [R, G, B]. + */ + normStd?: [number, number, number]; +} + +/** + * Postprocessor configuration for instance segmentation models. + * + * @category Types + */ +export interface PostprocessorConfig { + /** + * Model type for postprocessing. + */ + type: 'yolo' | 'rfdetr'; + /** + * Default confidence threshold for this model. + */ + defaultConfidenceThreshold?: number; + /** + * Default IoU threshold for NMS for this model. + */ + defaultIouThreshold?: number; + /** + * Whether to apply Non-Maximum Suppression (NMS). Default: true + * If true, NMS will be applied using the specified or default IoU threshold. + */ + applyNMS?: boolean; +} + +/** + * Options for instance segmentation forward pass. + * + * @typeParam L - The {@link LabelEnum} type for the model. + * @category Types + */ +export interface InstanceSegmentationOptions { + /** + * Minimum confidence threshold for including instances. + * Defaults to model's defaultConfidenceThreshold (typically 0.5). + */ + confidenceThreshold?: number; + /** + * IoU threshold for non-maximum suppression. + * Defaults to model's defaultIouThreshold (typically 0.45). + */ + iouThreshold?: number; + /** + * Maximum number of instances to return. Default: 100 + */ + maxInstances?: number; + /** + * Filter to include only specific classes. + */ + classesOfInterest?: (keyof L)[]; + /** + * Whether to return masks at original image resolution. Default: true + */ + returnMaskAtOriginalResolution?: boolean; + /** + * Input size for the model (e.g., 384, 416, 512, 640, 1024). + * Must be one of the model's availableInputSizes. + * Defaults to model's defaultInputSize. + */ + inputSize?: number; +} + +/** + * Configuration for custom instance segmentation model. + * + * @typeParam T - The {@link LabelEnum} type for the model. + * @property labelMap - The enum-like object mapping class names to indices + * @property availableInputSizes - (Optional) Array of supported input sizes for multi-method models (e.g., [384, 416, 512, 640, 1024]) + * @property defaultInputSize - (Optional) Default input size to use if not specified. Required if availableInputSizes is provided + * @property preprocessorConfig - Optional preprocessing configuration (normalization, etc.) + * @property postprocessorConfig - Postprocessing configuration (type, thresholds, etc.) + * + * @remarks + * **Multi-Method Models (e.g., YOLO):** + * - Provide both `availableInputSizes` and `defaultInputSize` + * - Model must have separate methods like `forward_384`, `forward_512`, `forward_640` + * - Input size can be specified in {@link InstanceSegmentationOptions.inputSize} + * - Input size will be validated against availableInputSizes + * + * @example + * ```typescript + * // Multi-method model config (YOLO) + * const yoloConfig = { + * labelMap: CocoLabel, + * availableInputSizes: [384, 416, 512, 640, 1024], + * defaultInputSize: 640, + * postprocessorConfig: { + * defaultConfidenceThreshold: 0.5, + * defaultIouThreshold: 0.45, + * applyNMS: false // YOLO already applies NMS internally + * } + * }; + * ``` + * + * **Single-Method Models (e.g., RFDetr):** + * - Omit both `availableInputSizes` and `defaultInputSize` + * - Model must have a single `forward` method + * - Input shape is auto-detected from model metadata + * - {@link InstanceSegmentationOptions.inputSize} parameter is ignored (with warning) + * + * @example + * ```typescript + * // Single-method model config (RFDetr) + * const rfdetrConfig = { + * labelMap: CocoLabel, + * postprocessorConfig: { + * defaultConfidenceThreshold: 0.5, + * applyNMS: true // RFDetr needs NMS to be applied + * } + * }; + * ``` + * + * @category Types + */ +export type InstanceSegmentationConfig = { + labelMap: T; + availableInputSizes?: readonly number[]; + defaultInputSize?: number; + preprocessorConfig?: PreprocessorConfig; + postprocessorConfig: PostprocessorConfig; +}; + +/// We would bind it here - but we need a deafult conf for yolo to be applied instead of +/** + * Per-model config for {@link InstanceSegmentationModule.fromModelName}. + * Each model name maps to its required fields. + * + * @category Types + */ +export type InstanceSegmentationModelSources = + | { modelName: 'yolo26n-seg'; modelSource: ResourceSource } + | { modelName: 'yolo26s-seg'; modelSource: ResourceSource } + | { modelName: 'yolo26m-seg'; modelSource: ResourceSource } + | { modelName: 'yolo26l-seg'; modelSource: ResourceSource } + | { modelName: 'yolo26x-seg'; modelSource: ResourceSource }; + +/** + * Union of all built-in instance segmentation model names. + * + * @category Types + */ +export type InstanceSegmentationModelName = + InstanceSegmentationModelSources['modelName']; + +/** + * Extracts the instance segmentation model name from a {@link InstanceSegmentationModelSources} config object. + * + * @category Types + */ +export type InstanceModelNameOf = + C['modelName']; + +/** + * Props for the `useInstanceSegmentation` hook. + * + * @typeParam C - A {@link InstanceSegmentationModelSources} config specifying which built-in model to load. + * @property model - The model config containing `modelName` and `modelSource`. + * @property {boolean} [preventLoad] - Boolean that can prevent automatic model loading (and downloading the data if you load it for the first time) after running the hook. + * + * @category Types + */ +export interface InstanceSegmentationProps< + C extends InstanceSegmentationModelSources, +> { + model: C; + preventLoad?: boolean; +} + +/** + * Return type for the `useInstanceSegmentation` hook. + * Manages the state and operations for instance segmentation models. + * + * @typeParam L - The {@link LabelEnum} representing the model's class labels. + * + * @category Types + */ +export interface InstanceSegmentationType { + /** + * Contains the error object if the model failed to load, download, or encountered a runtime error during segmentation. + */ + error: RnExecutorchError | null; + + /** + * Indicates whether the instance segmentation model is loaded and ready to process images. + */ + isReady: boolean; + + /** + * Indicates whether the model is currently processing an image. + */ + isGenerating: boolean; + + /** + * Represents the download progress of the model binary as a value between 0 and 1. + */ + downloadProgress: number; + + /** + * Executes the model's forward pass to perform instance segmentation on the provided image. + * @param imageSource - A string representing the image source (e.g., a file path, URI, or base64 string) to be processed. + * @param options - Optional configuration for the segmentation process. + * @returns A Promise resolving to an array of instance masks. + * @throws {RnExecutorchError} If the model is not loaded or is currently processing another image. + */ + forward: ( + imageSource: string, + options?: InstanceSegmentationOptions + ) => Promise[]>; +} diff --git a/skills/canary/react-native-executorch/references/reference-cv.md b/skills/canary/react-native-executorch/references/reference-cv.md index 171b14a41..abe4ee7f0 100644 --- a/skills/canary/react-native-executorch/references/reference-cv.md +++ b/skills/canary/react-native-executorch/references/reference-cv.md @@ -1,6 +1,6 @@ --- title: Computer Vision models usage -description: Reference for using Image Classification, Semantic Segmentation, and Object Detection models. +description: Reference for using Image Classification, Image Segmentation, and Object Detection models. --- # useClassification @@ -139,8 +139,8 @@ For the latest available models check out exported models in [this HuggingFace S ## Additional references -- [useSemanticSegmentation docs](https://docs.swmansion.com/react-native-executorch/docs/hooks/computer-vision/useSemanticSegmentation) -- useSemanticSegmentation API reference](https://docs.swmansion.com/react-native-executorch/docs/api-reference/functions/useSemanticSegmentation) +- [useSemanticSegmentation docs](https://docs.swmansion.com/react-native-executorch/docs/hooks/computer-vision/useImageSegmentation) +- useSemanticSegmentation API reference](https://docs.swmansion.com/react-native-executorch/docs/api-reference/functions/useImageSegmentation) - [HuggingFace Segmentation collection](https://huggingface.co/collections/software-mansion/image-segmentation) - [Typescript API implementation of segmentation](https://docs.swmansion.com/react-native-executorch/docs/typescript-api/computer-vision/SemanticSegmentationModule) diff --git a/skills/react-native-executorch/references/reference-cv.md b/skills/react-native-executorch/references/reference-cv.md index 52fcf3093..3bb24acd0 100644 --- a/skills/react-native-executorch/references/reference-cv.md +++ b/skills/react-native-executorch/references/reference-cv.md @@ -1,6 +1,6 @@ --- title: Computer Vision models usage -description: Reference for using Image Classification, Semantic Segmentation, and Object Detection models. +description: Reference for using Image Classification, Image Segmentation, and Object Detection models. --- # useClassification @@ -139,8 +139,8 @@ For the latest available models check out exported models in [this HuggingFace S ## Additional references -- [useSemanticSegmentation docs](https://docs.swmansion.com/react-native-executorch/docs/hooks/computer-vision/useSemanticSegmentation) -- [useSemanticSegmentation API reference](https://docs.swmansion.com/react-native-executorch/docs/api-reference/functions/useSemanticSegmentation) +- [useSemanticSegmentation docs](https://docs.swmansion.com/react-native-executorch/docs/hooks/computer-vision/useImageSegmentation) +- [useSemanticSegmentation API reference](https://docs.swmansion.com/react-native-executorch/docs/api-reference/functions/useImageSegmentation) - [HuggingFace Segmentation collection](https://huggingface.co/collections/software-mansion/image-segmentation) - [Typescript API implementation of segmentation](https://docs.swmansion.com/react-native-executorch/docs/typescript-api/computer-vision/SemanticSegmentationModule) diff --git a/yarn.lock b/yarn.lock index f839c07a6..2aebff30a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4457,6 +4457,16 @@ __metadata: languageName: unknown linkType: soft +"@react-native-picker/picker@npm:^2.11.4": + version: 2.11.4 + resolution: "@react-native-picker/picker@npm:2.11.4" + peerDependencies: + react: "*" + react-native: "*" + checksum: 10/cb8f0b7bf52044a5bbb89db5a3f1be7bd3cdf3a04845f0475c492ec3f24e63cd915b993b23012b674d3503499efd8ff4eebe18561f4e38ba67b4c45742de4c74 + languageName: node + linkType: hard + "@react-native/assets-registry@npm:0.81.5": version: 0.81.5 resolution: "@react-native/assets-registry@npm:0.81.5" @@ -7241,6 +7251,7 @@ __metadata: dependencies: "@babel/core": "npm:^7.29.0" "@react-native-executorch/expo-resource-fetcher": "workspace:*" + "@react-native-picker/picker": "npm:^2.11.4" "@react-native/metro-config": "npm:^0.81.5" "@react-navigation/drawer": "npm:^7.8.1" "@react-navigation/native": "npm:^7.1.28"