Skip to content

Commit b2fa3be

Browse files
committed
Apply revies suggestions
1 parent c2645ca commit b2fa3be

File tree

3 files changed

+712
-716
lines changed

3 files changed

+712
-716
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,14 @@ std::vector<types::Instance> BaseInstanceSegmentation::postprocess(
315315
static_cast<float>(originalSize.width) / modelInputSize.width;
316316
float heightRatio =
317317
static_cast<float>(originalSize.height) / modelInputSize.height;
318-
std::set<int32_t> allowedClasses = prepareAllowedClasses(classIndices);
318+
auto allowedClasses = prepareAllowedClasses(classIndices);
319319

320320
// CONTRACT
321321
auto bboxTensor = tensors[0].toTensor(); // [1, N, 4]
322322
auto scoresTensor = tensors[1].toTensor(); // [1, N, 2]
323323
auto maskTensor = tensors[2].toTensor(); // [1, N, H, W]
324324

325-
int32_t N = bboxTensor.size(1);
325+
int32_t numInstances = bboxTensor.size(1);
326326
int32_t maskH = maskTensor.size(2);
327327
int32_t maskW = maskTensor.size(3);
328328

@@ -343,7 +343,7 @@ std::vector<types::Instance> BaseInstanceSegmentation::postprocess(
343343

344344
std::vector<types::Instance> instances;
345345

346-
for (int32_t i = 0; i < N; ++i) {
346+
for (int32_t i = 0; i < numInstances; ++i) {
347347
auto [bboxModel, score, labelIdx] =
348348
extractDetectionData(bboxData, scoresData, i);
349349

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ export interface InstanceSegmentationOptions<L extends LabelEnum> {
8080
*
8181
* @typeParam T - The label map type for the model, must conform to {@link LabelEnum}.
8282
* @category Types
83+
*
84+
* @remarks
85+
* The `availableInputSizes` and `defaultInputSize` fields are mutually inclusive:
86+
* - **Either both must be provided** (for models with multiple input sizes), or
87+
* - **Both must be omitted** (for models with a single input size).
88+
*
89+
* This discriminated union ensures type safety and prevents partial configuration.
8390
*/
8491
export type InstanceSegmentationConfig<T extends LabelEnum> = {
8592
labelMap: T;

0 commit comments

Comments
 (0)