Skip to content

Commit bac2b69

Browse files
committed
Remove console.logs, change error type
1 parent ab4c33c commit bac2b69

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

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

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,12 @@ export default function InstanceSegmentationTask({
7373
imageWidth: number;
7474
imageHeight: number;
7575
}) => {
76-
console.log(`[${activeModel}] Got ${p.results.length} instances`);
77-
if (p.results.length > 0) {
78-
const first = p.results[0];
79-
console.log(`[${activeModel}] First instance:`, {
80-
label: first.label,
81-
score: first.score,
82-
bbox: first.bbox,
83-
maskWidth: first.maskWidth,
84-
maskHeight: first.maskHeight,
85-
maskSize: first.mask.length,
86-
});
87-
}
8876
const displayInstances = buildDisplayInstances(
8977
p.results.map((inst) => ({
9078
...inst,
9179
label: String(inst.label),
9280
}))
9381
);
94-
console.log(
95-
`[${activeModel}] Built ${displayInstances.length} display instances`
96-
);
9782
setInstances((prev) => {
9883
// Dispose old mask images
9984
prev.forEach((inst) => inst.maskImage.dispose());
@@ -105,7 +90,7 @@ export default function InstanceSegmentationTask({
10590
if (diff > 0) onFpsChange(Math.round(1000 / diff), diff);
10691
lastFrameTimeRef.current = now;
10792
},
108-
[onFpsChange, activeModel]
93+
[onFpsChange]
10994
);
11095

11196
const frameOutput = useFrameOutput({

packages/react-native-executorch/common/rnexecutorch/models/instance_segmentation/BaseInstanceSegmentation.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <cmath>
44
#include <cstdint>
5-
#include <iostream>
65
#include <rnexecutorch/Error.h>
76
#include <rnexecutorch/ErrorCodes.h>
87
#include <rnexecutorch/Log.h>
@@ -234,7 +233,7 @@ void BaseInstanceSegmentation::validateThresholds(double confidenceThreshold,
234233
void BaseInstanceSegmentation::validateOutputTensors(
235234
const std::vector<EValue> &tensors) const {
236235
if (tensors.size() != 3) {
237-
throw RnExecutorchError(RnExecutorchErrorCode::UnexpectedNumInputs,
236+
throw RnExecutorchError(RnExecutorchErrorCode::InvalidModelOutput,
238237
"Expected 3 output tensors ([1,N,4] + [1,N,2] + "
239238
"[1,N,H,W]), got " +
240239
std::to_string(tensors.size()));
@@ -268,13 +267,13 @@ void BaseInstanceSegmentation::ensureMethodLoaded(
268267
if (!currentlyLoadedMethod_.empty()) {
269268
module_->unload_method(currentlyLoadedMethod_);
270269
}
271-
currentlyLoadedMethod_ = methodName;
272270
auto loadResult = module_->load_method(methodName);
273271
if (loadResult != executorch::runtime::Error::Ok) {
274272
throw RnExecutorchError(
275273
loadResult, "Failed to load method '" + methodName +
276274
"'. Ensure the method exists in the exported model.");
277275
}
276+
currentlyLoadedMethod_ = methodName;
278277
}
279278

280279
std::vector<types::Instance> BaseInstanceSegmentation::finalizeInstances(

packages/react-native-executorch/src/types/instanceSegmentation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RnExecutorchError } from '../errors/errorUtils';
2-
import { LabelEnum, ResourceSource, Triple, Frame } from './common';
2+
import { LabelEnum, ResourceSource, Triple, Frame, PixelData } from './common';
33
import { Bbox } from './objectDetection';
44

55
/**
@@ -185,13 +185,13 @@ export interface InstanceSegmentationType<L extends LabelEnum> {
185185

186186
/**
187187
* Executes the model's forward pass to perform instance segmentation on the provided image.
188-
* @param imageSource - A string representing the image source (e.g., a file path, URI, or base64 string) to be processed.
188+
* @param imageSource - A string (e.g., a file path, URI ) or PixelData representing the image source to be processed.
189189
* @param options - Optional configuration for the segmentation process.
190190
* @returns A Promise resolving to an array of {@link SegmentedInstance} objects.
191191
* @throws {RnExecutorchError} If the model is not loaded or is currently processing another image.
192192
*/
193193
forward: (
194-
imageSource: string,
194+
imageSource: string | PixelData,
195195
options?: InstanceSegmentationOptions<L>
196196
) => Promise<SegmentedInstance<L>[]>;
197197

0 commit comments

Comments
 (0)