Skip to content

Commit f957253

Browse files
committed
hehe
1 parent 821d1ed commit f957253

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

apps/computer-vision/app/image_segmentation/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default function ImageSegmentationScreen() {
8989
setIsGenerating(true);
9090
const { width, height } = imageSize;
9191
const t1 = performance.now();
92-
const output = await model.forward(imageUri, [], true);
92+
const output = await model.forward(imageUri, ['PERSON'], true);
9393
const t2 = performance.now();
9494
console.log(t2 - t1);
9595
const argmax = output['ARGMAX'] || [];

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ export class ImageSegmentation<
102102
const normMean = [...(preprocessorConfig?.normMean ?? [])];
103103
const normStd = [...(preprocessorConfig?.normStd ?? [])];
104104
const paths = await ResourceFetcher.fetch(onDownloadProgress, modelSource);
105-
if (paths === null || paths.length < 1) {
105+
if (!paths?.[0]) {
106106
throw new RnExecutorchError(
107107
RnExecutorchErrorCode.DownloadInterrupted,
108108
'The download has been interrupted. Please retry.'
109109
);
110110
}
111111
const nativeModule = global.loadImageSegmentation(
112-
paths[0] || '',
112+
paths[0],
113113
normMean,
114114
normStd
115115
);
@@ -143,18 +143,12 @@ export class ImageSegmentation<
143143
onDownloadProgress: (progress: number) => void = () => {}
144144
): Promise<ImageSegmentation<L>> {
145145
const paths = await ResourceFetcher.fetch(onDownloadProgress, modelSource);
146-
if (paths === null || paths.length < 1) {
146+
if (!paths?.[0]) {
147147
throw new RnExecutorchError(
148148
RnExecutorchErrorCode.DownloadInterrupted,
149149
'The download has been interrupted. Please retry.'
150150
);
151151
}
152-
if (!paths[0]) {
153-
throw new RnExecutorchError(
154-
RnExecutorchErrorCode.DownloadInterrupted,
155-
"The download couldn't be completed. Please retry."
156-
);
157-
}
158152
const normMean = config.preprocessorConfig?.normMean ?? [];
159153
const normStd = config.preprocessorConfig?.normStd ?? [];
160154
const nativeModule = global.loadImageSegmentation(

0 commit comments

Comments
 (0)