Skip to content

Commit fb1afc8

Browse files
committed
docs: update docs
1 parent 722480b commit fb1afc8

6 files changed

Lines changed: 3999 additions & 4002 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, 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. |
63+
| Field | Type | Description |
64+
| ------------------ | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
65+
| `forward` | `(input: string, detectionThreshold: number = 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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const classesWithProbabilities = await module.forward(imageUri);
2525

2626
### Methods
2727

28-
| Method | Type | Description |
29-
| -------------------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
30-
| `load` | `(modelSource: ResourceSource): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary. |
31-
| `forward` | `(input: string): Promise<{ [category: string]: number }>` | Executes the model's forward pass, where `input` can be a fetchable resource or a Base64-encoded string. |
32-
| `onDownloadProgress` | `(callback: (downloadProgress: number) => void): any` | Subscribe to the download progress event. |
28+
| Method | Type | Description |
29+
| --------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
30+
| `load` | `(modelSource: ResourceSource, onDownloadProgressCallback: (_: number) => void () => {}): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary. To track the download progress, supply a callback function `onDownloadProgressCallback`. |
31+
| `forward` | `(input: string): Promise<{ [category: string]: number }>` | Executes the model's forward pass, where `input` can be a fetchable resource or a Base64-encoded string. |
32+
| `delete` | `(): void` | Release the memory held by the module. Calling `forward` afterwards is invalid. |
3333

3434
<details>
3535
<summary>Type definitions</summary>
@@ -47,3 +47,7 @@ To load the model, create a new instance of the module and use the `load` method
4747
## Running the model
4848

4949
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.
50+
51+
## Managing memory
52+
53+
The module is a regular JavaScript object, and as such its lifespan will be managed by the garbage collector. In most cases this should be enough, and you should not worry about freeing the memory of the module yourself, but in some cases you may want to release the memory occupied by the module before the garbage collector steps in. In this case use the method `delete()` on the module object you will no longer use, and want to remove from the memory. Note that you cannot use `forward` after `delete` unless you load the module again.

docs/docs/typescript-api/ImageSegmentationModule.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ const outputDict = await module.forward(imageUri);
2525

2626
### Methods
2727

28-
| Method | Type | Description |
29-
| -------------------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30-
| `load` | `(modelSource: ResourceSource): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary. |
31-
| `forward` | `(input: string, classesOfInterest?: DeeplabLabel[], resize?: boolean) => Promise<{[key in DeeplabLabel]?: number[]}>` | Executes the model's forward pass, where : <br/> \* `input` can be a fetchable resource or a Base64-encoded string. <br/> \* `classesOfInterest` is an optional list of `DeeplabLabel` used to indicate additional arrays of probabilities to output (see section "Running the model"). The default is an empty list. <br/> \* `resize` is an optional boolean to indicate whether the output should be resized to the original image dimensions, or left in the size of the model (see section "Running the model"). The default is `false`. <br/> <br/> The return is a dictionary containing: <br/> \* for the key `DeeplabLabel.ARGMAX` an array of integers corresponding to the most probable class for each pixel <br/> \* an array of floats for each class from `classesOfInterest` corresponding to the probabilities for this class. |
32-
| `onDownloadProgress` | `(callback: (downloadProgress: number) => void): any` | Subscribe to the download progress event. |
28+
| Method | Type | Description |
29+
| --------- | ---------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30+
| `load` | `(modelSource: ResourceSource, onDownloadProgressCallback: (_: number) => void () => {}): Promise<void>` | Loads the model, where `modelSource` is a string that specifies the location of the model binary. To track the download progress, supply a callback function `onDownloadProgressCallback`. |
31+
| `forward` | `(input: string, classesOfInterest?: DeeplabLabel[], resize?: boolean) => Promise<{[key in DeeplabLabel]?: number[]}>` | Executes the model's forward pass, where : <br/> \* `input` can be a fetchable resource or a Base64-encoded string. <br/> \* `classesOfInterest` is an optional list of `DeeplabLabel` used to indicate additional arrays of probabilities to output (see section "Running the model"). The default is an empty list. <br/> \* `resize` is an optional boolean to indicate whether the output should be resized to the original image dimensions, or left in the size of the model (see section "Running the model"). The default is `false`. <br/> <br/> The return is a dictionary containing: <br/> \* for the key `DeeplabLabel.ARGMAX` an array of integers corresponding to the most probable class for each pixel <br/> \* an array of floats for each class from `classesOfInterest` corresponding to the probabilities for this class. |
32+
| `delete` | `(): void` | Release the memory held by the module. Calling `forward` afterwards is invalid. |
3333

3434
<details>
3535
<summary>Type definitions</summary>
@@ -60,3 +60,7 @@ Setting `resize` to true will make `forward` slower.
6060

6161
- For the key `DeeplabLabel.ARGMAX` the array contains for each pixel an integer corresponding to the class with the highest probability.
6262
- For every other key from `DeeplabLabel`, if the label was included in `classesOfInterest` the dictionary will contain an array of floats corresponding to the probability of this class for every pixel.
63+
64+
## Managing memory
65+
66+
The module is a regular JavaScript object, and as such its lifespan will be managed by the garbage collector. In most cases this should be enough, and you should not worry about freeing the memory of the module yourself, but in some cases you may want to release the memory occupied by the module before the garbage collector steps in. In this case use the method `delete()` on the module object you will no longer use, and want to remove from the memory. Note that you cannot use `forward` after `delete` unless you load the module again.

0 commit comments

Comments
 (0)