@@ -60,12 +60,31 @@ type ResolveLabels<T extends InstanceSegmentationModelName | LabelEnum> =
6060
6161/**
6262 * Generic instance segmentation module with type-safe label maps.
63- * Use a model name (e.g. `'yolo26n-seg'`) as the generic parameter for built-in models,
63+ * Use a model name (e.g. `'yolo26n-seg'`) as the generic parameter for pre-configured models,
6464 * or a custom label enum for custom configs.
6565 *
66- * @typeParam T - Either a built-in model name or a custom {@link LabelEnum} label map.
66+ * Supported models (download from HuggingFace):
67+ * - `yolo26n-seg`, `yolo26s-seg`, `yolo26m-seg`, `yolo26l-seg`, `yolo26x-seg` - YOLO models with COCO labels (80 classes)
68+ *
69+ * @typeParam T - Either a pre-configured model name from {@link InstanceSegmentationModelName}
70+ * or a custom {@link LabelEnum} label map.
6771 *
6872 * @category Typescript API
73+ *
74+ * @example
75+ * ```ts
76+ * const segmentation = await InstanceSegmentationModule.fromModelName({
77+ * modelName: 'yolo26n-seg',
78+ * modelSource: 'https://huggingface.co/.../yolo26n-seg.pte',
79+ * });
80+ *
81+ * const results = await segmentation.forward('path/to/image.jpg', {
82+ * confidenceThreshold: 0.5,
83+ * iouThreshold: 0.45,
84+ * maxInstances: 20,
85+ * inputSize: 640,
86+ * });
87+ * ```
6988 */
7089export class InstanceSegmentationModule <
7190 T extends InstanceSegmentationModelName | LabelEnum ,
@@ -88,7 +107,7 @@ export class InstanceSegmentationModule<
88107 override async load ( ) { }
89108
90109 /**
91- * Creates an instance segmentation module for a built-in model.
110+ * Creates an instance segmentation module for a pre-configured model.
92111 * The config object is discriminated by `modelName` — each model can require different fields.
93112 *
94113 * @param config - A {@link InstanceSegmentationModelSources} object specifying which model to load and where to fetch it from.
@@ -99,7 +118,7 @@ export class InstanceSegmentationModule<
99118 * ```ts
100119 * const segmentation = await InstanceSegmentationModule.fromModelName({
101120 * modelName: 'yolo26n-seg',
102- * modelSource: 'https://example.com /yolo26n-seg.pte',
121+ * modelSource: 'https://huggingface.co/... /yolo26n-seg.pte',
103122 * });
104123 * ```
105124 */
@@ -145,19 +164,29 @@ export class InstanceSegmentationModule<
145164
146165 /**
147166 * Creates an instance segmentation module with a user-provided label map and custom config.
148- * Use this when working with a custom-exported segmentation model that is not one of the built-in models.
167+ * Use this when working with a custom-exported segmentation model that is not one of the pre-configured models.
149168 *
150169 * @param modelSource - A fetchable resource pointing to the model binary.
151- * @param config - A {@link InstanceSegmentationConfig} object with the label map.
170+ * @param config - A {@link InstanceSegmentationConfig} object with the label map and optional preprocessing parameters .
152171 * @param onDownloadProgress - Optional callback to monitor download progress, receiving a value between 0 and 1.
153172 * @returns A Promise resolving to an `InstanceSegmentationModule` instance typed to the provided label map.
154173 *
155174 * @example
156175 * ```ts
157176 * const MyLabels = { PERSON: 0, CAR: 1 } as const;
158177 * const segmentation = await InstanceSegmentationModule.fromCustomConfig(
159- * 'https://example.com/custom_model.pte',
160- * { labelMap: MyLabels },
178+ * 'https://huggingface.co/.../custom_model.pte',
179+ * {
180+ * labelMap: MyLabels,
181+ * availableInputSizes: [640],
182+ * defaultInputSize: 640,
183+ * postprocessorConfig: {
184+ * type: 'yolo',
185+ * defaultConfidenceThreshold: 0.5,
186+ * defaultIouThreshold: 0.45,
187+ * applyNMS: true,
188+ * },
189+ * },
161190 * );
162191 * ```
163192 */
@@ -201,9 +230,25 @@ export class InstanceSegmentationModule<
201230 * Executes the model's forward pass to perform instance segmentation on the provided image.
202231 *
203232 * @param imageSource - A string representing the image source (e.g., a file path, URI, or Base64-encoded string).
204- * @param options - Optional configuration for the segmentation process.
205- * @returns A Promise resolving to an array of instance masks.
206- * @throws {RnExecutorchError } If the model is not loaded.
233+ * @param options - Optional configuration for the segmentation process. Includes `confidenceThreshold`, `iouThreshold`, `maxInstances`, `classesOfInterest`, `returnMaskAtOriginalResolution`, and `inputSize`.
234+ * @returns A Promise resolving to an array of {@link SegmentedInstance} objects with `bbox`, `mask`, `maskWidth`, `maskHeight`, `label`, `score`, and `instanceId`.
235+ * @throws {RnExecutorchError } If the model is not loaded or if an invalid `inputSize` is provided.
236+ *
237+ * @example
238+ * ```ts
239+ * const results = await segmentation.forward('path/to/image.jpg', {
240+ * confidenceThreshold: 0.6,
241+ * iouThreshold: 0.5,
242+ * maxInstances: 10,
243+ * inputSize: 640,
244+ * classesOfInterest: ['PERSON', 'CAR'],
245+ * returnMaskAtOriginalResolution: true,
246+ * });
247+ *
248+ * results.forEach((inst) => {
249+ * console.log(`${inst.label}: ${(inst.score * 100).toFixed(1)}%`);
250+ * });
251+ * ```
207252 */
208253 async forward (
209254 imageSource : string ,
0 commit comments