Skip to content

Commit 2a9f24e

Browse files
committed
Strengthen typing
1 parent 2565c94 commit 2a9f24e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

apps/computer-vision/app/vision_camera/tasks/InstanceSegmentationTask.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
YOLO26N_SEG,
88
RF_DETR_SEG,
99
useInstanceSegmentation,
10+
CocoLabel,
11+
CocoLabelYolo,
1012
} from 'react-native-executorch';
1113
import { Canvas, Image as SkiaImage } from '@shopify/react-native-skia';
1214
import { labelColor, labelColorBg } from '../utils/colors';
@@ -65,7 +67,9 @@ export default function InstanceSegmentationTask({
6567

6668
const updateInstances = useCallback(
6769
(p: {
68-
results: SegmentedInstance<any>[];
70+
results:
71+
| SegmentedInstance<typeof CocoLabel>[]
72+
| SegmentedInstance<typeof CocoLabelYolo>[];
6973
imageWidth: number;
7074
imageHeight: number;
7175
}) => {
@@ -140,7 +144,7 @@ export default function InstanceSegmentationTask({
140144
frame.dispose();
141145
}
142146
},
143-
[instSegRof, frameKillSwitch, updateInstances]
147+
[instSegRof, frameKillSwitch, updateInstances, activeModel]
144148
),
145149
});
146150

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ const ModelConfigs = {
7474
'yolo26l-seg': YOLO_SEG_CONFIG,
7575
'yolo26x-seg': YOLO_SEG_CONFIG,
7676
'rfdetr-seg': RF_DETR_SEG_CONFIG,
77-
} as const;
77+
} as const satisfies Record<
78+
InstanceSegmentationModelName,
79+
| InstanceSegmentationConfig<typeof CocoLabel>
80+
| InstanceSegmentationConfig<typeof CocoLabelYolo>
81+
>;
7882

7983
/** @internal */
8084
type ModelConfigsType = typeof ModelConfigs;

0 commit comments

Comments
 (0)