Skip to content

Commit 8c12eed

Browse files
committed
docs: update classification, segmentation and style transfer
1 parent 1adeac9 commit 8c12eed

4 files changed

Lines changed: 25 additions & 19 deletions

File tree

docs/docs/computer-vision/useObjectDetection.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ For more information on that topic, you can check out the [Loading models](https
6060

6161
The hook returns an object with the following properties:
6262

63-
| Field | Type | Description |
64-
| ------------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------- |
65-
| `forward` | `(input: string) => Promise<Detection[]>` | A function that accepts an image (url, b64) and returns an array of `Detection` objects. |
66-
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
67-
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
68-
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
69-
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
63+
| Field | Type | Description |
64+
| ------------------ | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
65+
| `forward` | `(input: string, detectionThreshold: float = 0.7) => Promise<Detection[]>` | A function that accepts an image (url, b64) and returns an array of `Detection` objects. `detectionThreshold` can be supplied to alter the sensitivity of the detection. |
66+
| `error` | <code>string &#124; null</code> | Contains the error message if the model loading failed. |
67+
| `isGenerating` | `boolean` | Indicates whether the model is currently processing an inference. |
68+
| `isReady` | `boolean` | Indicates whether the model has successfully loaded and is ready for inference. |
69+
| `downloadProgress` | `number` | Represents the download progress as a value between 0 and 1. |
7070

7171
## Running the model
7272

docs/docs/typescript-api/ClassificationModule.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import {
1414

1515
const imageUri = 'path/to/image.png';
1616

17+
const module = new ClassificationModule();
18+
1719
// Loading the model
18-
await ClassificationModule.load(EFFICIENTNET_V2_S);
20+
await module.load(EFFICIENTNET_V2_S);
1921

2022
// Running the model
21-
const classesWithProbabilities = await ClassificationModule.forward(imageUri);
23+
const classesWithProbabilities = await module.forward(imageUri);
2224
```
2325

2426
### Methods
@@ -40,8 +42,8 @@ type ResourceSource = string | number | object;
4042

4143
## Loading the model
4244

43-
To load the model, use the `load` method. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
45+
To load the model, create a new instance of the module and use the `load` method on it. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
4446

4547
## Running the model
4648

47-
To run the model, you can use the `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The method returns a promise, which can resolve either to an error or an object containing categories with their probabilities.
49+
To run the model, you can use the `forward` method on the module object. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The method returns a promise, which can resolve either to an error or an object containing categories with their probabilities.

docs/docs/typescript-api/ImageSegmentationModule.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import {
1414

1515
const imageUri = 'path/to/image.png';
1616

17+
const module = new ImageSegmentationModule();
18+
1719
// Loading the model
18-
await ImageSegmentationModule.load(DEEPLAB_V3_RESNET50);
20+
await module.load(DEEPLAB_V3_RESNET50);
1921

2022
// Running the model
21-
const outputDict = await ImageSegmentationModule.forward(imageUri);
23+
const outputDict = await module.forward(imageUri);
2224
```
2325

2426
### Methods
@@ -40,11 +42,11 @@ type ResourceSource = string | number | object;
4042

4143
## Loading the model
4244

43-
To load the model, use the `load` method. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
45+
To load the model, create a new instance of the module and use the `load` method on it. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
4446

4547
## Running the model
4648

47-
To run the model, you can use the `forward` method. It accepts three arguments: a required image, an optional list of classes, and an optional flag whether to resize the output to the original dimensions.
49+
To run the model, you can use the `forward` method on the module object. It accepts three arguments: a required image, an optional list of classes, and an optional flag whether to resize the output to the original dimensions.
4850

4951
- The image can be a remote URL, a local file URI, or a base64-encoded image.
5052
- The `classesOfInterest` list contains classes for which to output the full results. By default the list is empty, and only the most probable classes are returned (essentially an arg max for each pixel). Look at `DeeplabLabel` enum for possible classes.

docs/docs/typescript-api/StyleTransferModule.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ import {
1414

1515
const imageUri = 'path/to/image.png';
1616

17+
const module = new StyleTransferModule();
18+
1719
// Loading the model
18-
await StyleTransferModule.load(STYLE_TRANSFER_CANDY);
20+
await module.load(STYLE_TRANSFER_CANDY);
1921

2022
// Running the model
21-
const generatedImageUrl = await StyleTransferModule.forward(imageUri);
23+
const generatedImageUrl = await module.forward(imageUri);
2224
```
2325

2426
### Methods
@@ -40,8 +42,8 @@ type ResourceSource = string | number | object;
4042

4143
## Loading the model
4244

43-
To load the model, use the `load` method. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
45+
To load the model, create a new instance of the module and use the `load` method on it. It accepts the `modelSource` which is a string that specifies the location of the model binary. For more information, take a look at [loading models](../fundamentals/loading-models.md) page. This method returns a promise, which can resolve to an error or void.
4446

4547
## Running the model
4648

47-
To run the model, you can use the `forward` method. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The method returns a promise, which can resolve either to an error or a URL to generated image.
49+
To run the model, you can use the `forward` method on the module object. It accepts one argument, which is the image. The image can be a remote URL, a local file URI, or a base64-encoded image. The method returns a promise, which can resolve either to an error or a URL to generated image.

0 commit comments

Comments
 (0)