Skip to content

Commit a22dd0f

Browse files
committed
final chores & docs
1 parent d5f00a7 commit a22dd0f

12 files changed

Lines changed: 56 additions & 50 deletions

File tree

docs/docs/04-typescript-api/01-natural-language-processing/LLMModule.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ The `capabilities` field is already set on the model constant. You can also cons
129129

130130
```typescript
131131
const llm = await LLMModule.fromModelName({
132-
modelName: 'custom',
133-
modelSource: '...',
134-
tokenizerSource: '...',
135-
tokenizerConfigSource: '...',
132+
modelName: 'lfm2.5-vl-1.6b-quantized',
133+
modelSource: require('./path/to/model.pte'),
134+
tokenizerSource: require('./path/to/tokenizer.json'),
135+
tokenizerConfigSource: require('./path/to/tokenizer_config.json'),
136136
capabilities: ['vision'],
137137
});
138138
```

docs/docs/04-typescript-api/01-natural-language-processing/TextToSpeechModule.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Use the static [`fromModelName`](../../06-api-reference/classes/TextToSpeechModu
3939
- [`model`](../../06-api-reference/interfaces/TextToSpeechConfig.md#model) - Model configuration (e.g. `KOKORO_MEDIUM`).
4040
- [`voice`](../../06-api-reference/interfaces/TextToSpeechConfig.md#voice) - Voice configuration (e.g. `KOKORO_VOICE_AF_HEART`).
4141

42-
- `onDownloadProgress` - Optional callback to track download progress (value between 0 and 1).
42+
- [`onDownloadProgress`](../../06-api-reference/classes/TextToSpeechModule.md#frommodelname) - Optional callback to track download progress (value between 0 and 1).
4343

4444
This method returns a promise that resolves to a `TextToSpeechModule` instance once the assets are downloaded and loaded into memory.
4545

docs/docs/04-typescript-api/01-natural-language-processing/VADModule.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ TypeScript API implementation of the [useVAD](../../03-hooks/01-natural-language
1414
```typescript
1515
import { VADModule, FSMN_VAD } from 'react-native-executorch';
1616

17-
const model = await VADModule.fromModelName(
18-
{ modelSource: FSMN_VAD },
19-
(progress) => console.log(progress)
17+
const model = await VADModule.fromModelName(FSMN_VAD, (progress) =>
18+
console.log(progress)
2019
);
2120

2221
await model.forward(waveform);
@@ -30,7 +29,8 @@ All methods of `VADModule` are explained in details here: [`VADModule` API Refer
3029

3130
To create a ready-to-use instance, call the static [`fromModelName`](../../06-api-reference/classes/VADModule.md#frommodelname) factory with the following parameters:
3231

33-
- `model` - Object containing:
32+
- `namedSources` - Object containing:
33+
- `modelName` - Model name identifier.
3434
- `modelSource` - Location of the model binary.
3535

3636
- `onDownloadProgress` - Optional callback to track download progress (value between 0 and 1).

docs/docs/04-typescript-api/02-computer-vision/ClassificationModule.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import {
2020
const imageUri = 'path/to/image.png';
2121

2222
// Creating and loading the module
23-
const classificationModule = await ClassificationModule.fromModelName({
24-
modelSource: EFFICIENTNET_V2_S,
25-
});
23+
const classificationModule =
24+
await ClassificationModule.fromModelName(EFFICIENTNET_V2_S);
2625

2726
// Running the model
2827
const classesWithProbabilities = await classificationModule.forward(imageUri);
@@ -36,7 +35,8 @@ All methods of `ClassificationModule` are explained in details here: [`Classific
3635

3736
To create a ready-to-use instance, call the static [`fromModelName`](../../06-api-reference/classes/ClassificationModule.md#frommodelname) factory with the following parameters:
3837

39-
- `model` - Object containing:
38+
- `namedSources` - Object containing:
39+
- `modelName` - Model name identifier.
4040
- `modelSource` - Location of the model binary.
4141

4242
- `onDownloadProgress` - Optional callback to track download progress (value between 0 and 1).

docs/docs/04-typescript-api/02-computer-vision/ImageEmbeddingsModule.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import {
1818
} from 'react-native-executorch';
1919

2020
// Creating and loading the module
21-
const imageEmbeddingsModule = await ImageEmbeddingsModule.fromModelName({
22-
modelSource: CLIP_VIT_BASE_PATCH32_IMAGE,
23-
});
21+
const imageEmbeddingsModule = await ImageEmbeddingsModule.fromModelName(
22+
CLIP_VIT_BASE_PATCH32_IMAGE
23+
);
2424

2525
// Running the model
2626
const embedding = await imageEmbeddingsModule.forward(
@@ -36,7 +36,8 @@ All methods of `ImageEmbeddingsModule` are explained in details here: [`ImageEmb
3636

3737
To create a ready-to-use instance, call the static [`fromModelName`](../../06-api-reference/classes/ImageEmbeddingsModule.md#frommodelname) factory with the following parameters:
3838

39-
- `model` - Object containing:
39+
- `namedSources` - Object containing:
40+
- `modelName` - Model name identifier.
4041
- `modelSource` - Location of the model binary.
4142

4243
- `onDownloadProgress` - Optional callback to track download progress (value between 0 and 1).

docs/docs/04-typescript-api/02-computer-vision/OCRModule.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ All methods of `OCRModule` are explained in details here: [`OCRModule` API Refer
2828

2929
## Loading the model
3030

31-
Use the static [`fromModelName`](../../06-api-reference/classes/OCRModule.md#frommodelname) factory method. It accepts a model config object (e.g. `OCR_ENGLISH`) containing:
31+
Use the static [`fromModelName`](../../06-api-reference/classes/OCRModule.md#frommodelname) factory method. It accepts a `namedSources` object (e.g. `OCR_ENGLISH`) containing:
3232

33+
- `modelName` - Model name identifier.
3334
- [`detectorSource`](../../06-api-reference/classes/OCRModule.md#detectorsource) - Location of the used detector.
3435
- [`recognizerSource`](../../06-api-reference/classes/OCRModule.md#recognizersource) - Location of the used recognizer.
3536
- [`language`](../../06-api-reference/classes/OCRModule.md#recognizersource) - Language used in OCR.

docs/docs/04-typescript-api/02-computer-vision/StyleTransferModule.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import {
2020
const imageUri = 'path/to/image.png';
2121

2222
// Creating and loading the module
23-
const styleTransferModule = await StyleTransferModule.fromModelName({
24-
modelSource: STYLE_TRANSFER_CANDY,
25-
});
23+
const styleTransferModule =
24+
await StyleTransferModule.fromModelName(STYLE_TRANSFER_CANDY);
2625

2726
// Running the model
2827
const generatedImageUrl = await styleTransferModule.forward(imageUri);
@@ -36,7 +35,8 @@ All methods of `StyleTransferModule` are explained in details here: [`StyleTrans
3635

3736
To create a ready-to-use instance, call the static [`fromModelName`](../../06-api-reference/classes/StyleTransferModule.md#frommodelname) factory with the following parameters:
3837

39-
- `model` - Object containing:
38+
- `namedSources` - Object containing:
39+
- `modelName` - Model name identifier.
4040
- `modelSource` - Location of the model binary.
4141

4242
- `onDownloadProgress` - Optional callback to track download progress (value between 0 and 1).

docs/docs/04-typescript-api/02-computer-vision/VerticalOCRModule.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ All methods of `VerticalOCRModule` are explained in details here: [`VerticalOCRM
2929

3030
## Loading the model
3131

32-
Use the static [`fromModelName`](../../06-api-reference/classes/VerticalOCRModule.md#frommodelname) factory method. It accepts a model config object (e.g. `{ ...OCR_ENGLISH, independentCharacters: true }`) containing:
32+
Use the static [`fromModelName`](../../06-api-reference/classes/VerticalOCRModule.md#frommodelname) factory method. It accepts a `namedSources` object (e.g. `{ ...OCR_ENGLISH, independentCharacters: true }`) containing:
3333

34+
- `modelName` - Model name identifier.
3435
- [`detectorSource`](../../06-api-reference/classes/VerticalOCRModule.md#detectorsource) - Location of the used detector.
3536
- [`recognizerSource`](../../06-api-reference/classes/VerticalOCRModule.md#recognizersource) - Location of the used recognizer.
3637
- [`language`](../../06-api-reference/classes/VerticalOCRModule.md#recognizersource) - Language used in OCR.

packages/react-native-executorch/src/modules/computer_vision/OCRModule.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { parseUnknownError } from '../../errors/errorUtils';
1212
export class OCRModule {
1313
private controller: OCRController;
1414

15-
private constructor() {
16-
this.controller = new OCRController();
15+
private constructor(controller: OCRController) {
16+
this.controller = controller;
1717
}
1818

1919
/**
@@ -38,15 +38,15 @@ export class OCRModule {
3838
},
3939
onDownloadProgress: (progress: number) => void = () => {}
4040
): Promise<OCRModule> {
41-
const instance = new OCRModule();
4241
try {
43-
await instance.controller.load(
42+
const controller = new OCRController();
43+
await controller.load(
4444
namedSources.detectorSource,
4545
namedSources.recognizerSource,
4646
namedSources.language,
4747
onDownloadProgress
4848
);
49-
return instance;
49+
return new OCRModule(controller);
5050
} catch (error) {
5151
Logger.error('Load failed:', error);
5252
throw parseUnknownError(error);

packages/react-native-executorch/src/modules/computer_vision/VerticalOCRModule.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import { OCRDetection, OCRLanguage, OCRModelName } from '../../types/ocr';
1212
export class VerticalOCRModule {
1313
private controller: VerticalOCRController;
1414

15-
private constructor() {
16-
this.controller = new VerticalOCRController();
15+
private constructor(controller: VerticalOCRController) {
16+
this.controller = controller;
1717
}
1818

1919
/**
@@ -39,16 +39,16 @@ export class VerticalOCRModule {
3939
},
4040
onDownloadProgress: (progress: number) => void = () => {}
4141
): Promise<VerticalOCRModule> {
42-
const instance = new VerticalOCRModule();
4342
try {
44-
await instance.controller.load(
43+
const controller = new VerticalOCRController();
44+
await controller.load(
4545
namedSources.detectorSource,
4646
namedSources.recognizerSource,
4747
namedSources.language,
4848
namedSources.independentCharacters ?? false,
4949
onDownloadProgress
5050
);
51-
return instance;
51+
return new VerticalOCRModule(controller);
5252
} catch (error) {
5353
Logger.error('Load failed:', error);
5454
throw parseUnknownError(error);

0 commit comments

Comments
 (0)