Skip to content

Commit 6255cf0

Browse files
committed
Fix docs and class filter
1 parent e07cdab commit 6255cf0

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

docs/docs/03-hooks/02-computer-vision/useInstanceSegmentation.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ For more information on loading resources, take a look at [loading models](../..
5858

5959
To run the model, use the [`forward`](../../06-api-reference/interfaces/InstanceSegmentationType.md#forward) method. It accepts two arguments:
6060

61-
- `imageSource` (required) - The image to process. Can be a remote URL, a local file URI, or a base64-encoded image (whole URI or only raw base64).
61+
- `imageSource` (required) - The image to process. Can be a remote URL, a local file URI, a base64-encoded image (whole URI or only raw base64), or a [`PixelData`](../../06-api-reference/interfaces/PixelData.md) object (raw RGB pixel buffer).
6262
- `options` (optional) - An [`InstanceSegmentationOptions`](../../06-api-reference/interfaces/InstanceSegmentationOptions.md) object with the following fields:
6363
- `confidenceThreshold` - Minimum confidence score for including instances. Defaults to the model's configured threshold (typically `0.5`).
6464
- `iouThreshold` - IoU threshold for non-maximum suppression. Defaults to `0.5`.
@@ -112,6 +112,10 @@ function App() {
112112
}
113113
```
114114

115+
## VisionCamera integration
116+
117+
See the full guide: [VisionCamera Integration](./visioncamera-integration.md).
118+
115119
## Supported models
116120

117121
:::info

docs/docs/03-hooks/02-computer-vision/visioncamera-integration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ The following hooks expose `runOnFrame`:
2020
- [`useOCR`](./useOCR.md)
2121
- [`useVerticalOCR`](./useVerticalOCR.md)
2222
- [`useObjectDetection`](./useObjectDetection.md)
23+
- [`useInstanceSegmentation`](./useInstanceSegmentation.md)
2324
- [`useSemanticSegmentation`](./useSemanticSegmentation.md)
2425
- [`useStyleTransfer`](./useStyleTransfer.md)
2526

docs/docs/04-typescript-api/02-computer-vision/InstanceSegmentationModule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ The model must produce **3 output tensors**:
112112

113113
To run the model, use the [`forward`](../../06-api-reference/classes/InstanceSegmentationModule.md#forward) method. It accepts two arguments:
114114

115-
- `imageSource` (required) - The image to process. Can be a remote URL, a local file URI, or a base64-encoded image (whole URI or only raw base64).
115+
- `imageSource` (required) - The image to process. Can be a remote URL, a local file URI, a base64-encoded image (whole URI or only raw base64), or a [`PixelData`](../../06-api-reference/interfaces/PixelData.md) object (raw RGB pixel buffer).
116116
- `options` (optional) - An [`InstanceSegmentationOptions`](../../06-api-reference/interfaces/InstanceSegmentationOptions.md) object for configuring the segmentation (confidence threshold, IoU threshold, input size, classes of interest, etc.).
117117

118118
The method returns a promise resolving to an array of [`SegmentedInstance`](../../06-api-reference/interfaces/SegmentedInstance.md) objects. Each object contains bounding box coordinates, a binary segmentation mask, a string `label` (resolved from the model's label enum), and the confidence score.

packages/react-native-executorch/common/rnexecutorch/tests/integration/BaseModelTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ constexpr auto kValidStyleTransferModelPath =
1919
// Common tests via typed test suite
2020
// ============================================================================
2121
namespace model_tests {
22+
23+
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(CommonModelTest);
24+
2225
template <> struct ModelTraits<BaseModel> {
2326
using ModelType = BaseModel;
2427

packages/react-native-executorch/src/modules/computer_vision/InstanceSegmentationModule.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,13 @@ export class InstanceSegmentationModule<
295295
this.classIndexToLabel.forEach((label, index) => {
296296
labelLookup[index] = label;
297297
});
298+
// Create reverse map (label → enum value) for classesOfInterest lookup
299+
const labelMap: Record<string, number> = {};
300+
for (const [name, value] of Object.entries(this.labelMap)) {
301+
if (typeof value === 'number') {
302+
labelMap[name] = value;
303+
}
304+
}
298305
const labelEnumOffset = this.labelEnumOffset;
299306
const defaultConfidenceThreshold =
300307
this.modelConfig.defaultConfidenceThreshold ?? 0.5;
@@ -320,7 +327,7 @@ export class InstanceSegmentationModule<
320327
const classIndices = options?.classesOfInterest
321328
? options.classesOfInterest.map((label) => {
322329
const labelStr = String(label);
323-
const enumValue = (labelLookup as any)[labelStr];
330+
const enumValue = labelMap[labelStr];
324331
return typeof enumValue === 'number'
325332
? enumValue - labelEnumOffset
326333
: -1;

0 commit comments

Comments
 (0)