@webex/ladon-ts 5.4.1 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +170 -163
- package/LICENSE +5 -5
- package/README.md +34 -36
- package/build/module/index.d.ts +10 -10
- package/build/module/lib/config-builder.d.ts +179 -180
- package/build/module/lib/config-types.d.ts +101 -101
- package/build/module/lib/config.d.ts +28 -29
- package/build/module/lib/generator.d.ts +73 -74
- package/build/module/lib/pipeline.d.ts +82 -83
- package/build/module/lib/preload.d.ts +7 -8
- package/build/module/lib/renderer/blur-renderer.d.ts +17 -18
- package/build/module/lib/renderer/ladon-renderer.d.ts +5 -6
- package/build/module/lib/renderer/passthrough-renderer.d.ts +10 -11
- package/build/module/lib/renderer/replacement-renderer.d.ts +14 -15
- package/build/module/lib/renderer/webgl-renderer.d.ts +23 -24
- package/build/module/lib/renderer.d.ts +5 -5
- package/build/module/lib/shared-resource-manager.d.ts +92 -92
- package/build/module/lib/util.d.ts +64 -64
- package/build/module/lib/version.d.ts +1 -1
- package/build/module/lib/version.js +1 -1
- package/build/module/lib/version.js.map +1 -1
- package/build/worker/ort-wasm-simd-threaded.wasm +0 -0
- package/build/worker/segmentation.js.map +1 -0
- package/package.json +101 -95
|
@@ -1,93 +1,93 @@
|
|
|
1
1
|
import { PreloadConfig, ResolutionConfig, WorkerConfig } from './config-types';
|
|
2
|
-
import * as ort from 'onnxruntime-web';
|
|
3
|
-
/**
|
|
4
|
-
* Shared resource manager used to preload and share resources across different pipelines.
|
|
5
|
-
* This is useful when multiple pipelines are using the same model or when the model needs
|
|
6
|
-
* to be preloaded before the pipeline is created.
|
|
7
|
-
*/
|
|
8
|
-
declare class SharedResourceManager {
|
|
9
|
-
private modelSessions;
|
|
10
|
-
private worker?;
|
|
11
|
-
private workerUrl?;
|
|
12
|
-
private resolvedUriCache;
|
|
13
|
-
/**
|
|
14
|
-
* Initialize the worker using the provided configuration.
|
|
15
|
-
*
|
|
16
|
-
* @param config - The configuration object.
|
|
17
|
-
* @returns A promise that resolves when the worker is initialized.
|
|
18
|
-
*/
|
|
19
|
-
initializeWorker(config: WorkerConfig): Promise<Worker>;
|
|
20
|
-
/**
|
|
21
|
-
* Terminate the worker.
|
|
22
|
-
*/
|
|
23
|
-
terminateWorker(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Load the model using the provided configuration. This gets called by the worker when using
|
|
26
|
-
* the worker generator.
|
|
27
|
-
*
|
|
28
|
-
* @param config - The configuration object.
|
|
29
|
-
* @returns A promise that resolves when the model is preloaded.
|
|
30
|
-
*/
|
|
31
|
-
loadModel(config: PreloadConfig): Promise<ort.InferenceSession>;
|
|
32
|
-
/**
|
|
33
|
-
* Preload the worker using the provided configuration.
|
|
34
|
-
*
|
|
35
|
-
* @param config - The configuration object.
|
|
36
|
-
* @returns A promise that resolves when the worker is preloaded.
|
|
37
|
-
*/
|
|
38
|
-
preloadWorker(config: PreloadConfig): Promise<void>;
|
|
39
|
-
/**
|
|
40
|
-
* Warmup the model session with a dummy input to avoid latency when running the model for the first time.
|
|
41
|
-
*
|
|
42
|
-
* @param {ort.InferenceSession} session The model session.
|
|
43
|
-
* @param {ResolutionConfig} inputSize The input size of the model.
|
|
44
|
-
* @param {number} inputChannels The number of input channels (e.g., RGB is 3).
|
|
45
|
-
* @param {ort.Tensor.Type} inputType The input tensor type.
|
|
46
|
-
* @returns {Promise<void>} A promise that resolves when the model is warmed up.
|
|
47
|
-
* @example
|
|
48
|
-
* await warmupModel(session, inputSize, inputChannels, inputType);
|
|
49
|
-
*/
|
|
50
|
-
warmupModel(session: ort.InferenceSession, inputSize?: ResolutionConfig, inputChannels?: number, inputType?: ort.Tensor.Type): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Get the model session for the provided model URL.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} modelUrl The model URL.
|
|
55
|
-
* @returns {ort.InferenceSession} The model session.
|
|
56
|
-
* @example
|
|
57
|
-
* const session = getModelSession(modelUrl);
|
|
58
|
-
*/
|
|
59
|
-
getModelSession(modelUrl: string): ort.InferenceSession;
|
|
60
|
-
/**
|
|
61
|
-
* Resolves the full URL for a given asset. Non-file URIs are treated as paths
|
|
62
|
-
* and resolved using the `toAbsoluteURI` method.
|
|
63
|
-
*
|
|
64
|
-
* @param config - The preload configuration.
|
|
65
|
-
* @param assetUri - The asset URI from the config.
|
|
66
|
-
* @returns The resolved full URL.
|
|
67
|
-
*/
|
|
68
|
-
/**
|
|
69
|
-
* Resolves the full URL for a given asset. Non-file URIs are treated as paths and resolved
|
|
70
|
-
* using the `toAbsoluteURI` method. If the assetUri is already resolved, or if it's found in
|
|
71
|
-
* cache, it will be returned directly. If an assetUrlResolver function is provided in the
|
|
72
|
-
* configuration, it will be used to resolve the URL if the assetUri is not fully qualified,
|
|
73
|
-
* a blob URL, or in the cache.
|
|
74
|
-
*
|
|
75
|
-
* @param config - The preload configuration.
|
|
76
|
-
* @param assetUri - The asset URI from the config.
|
|
77
|
-
* @returns The resolved full URL.
|
|
78
|
-
*/
|
|
79
|
-
resolveUri(config: PreloadConfig, assetUri?: string): Promise<string>;
|
|
80
|
-
getWorker(): Worker | undefined;
|
|
81
|
-
getWorkerUrl(): string | undefined;
|
|
82
|
-
/**
|
|
83
|
-
* Prepare the worker configuration by resolving the final URLs and paths to send to the
|
|
84
|
-
* worker. This is necessary because we can't send functions to the worker. We also need to
|
|
85
|
-
* remove the assetUrlResolver function from the configuration.
|
|
86
|
-
*
|
|
87
|
-
* @param config - The preload configuration.
|
|
88
|
-
* @returns The worker configuration.
|
|
89
|
-
*/
|
|
90
|
-
prepareWorkerConfig(config: PreloadConfig): Promise<any>;
|
|
91
|
-
}
|
|
92
|
-
export declare const sharedResourceManager: SharedResourceManager;
|
|
93
|
-
export {};
|
|
2
|
+
import * as ort from 'onnxruntime-web';
|
|
3
|
+
/**
|
|
4
|
+
* Shared resource manager used to preload and share resources across different pipelines.
|
|
5
|
+
* This is useful when multiple pipelines are using the same model or when the model needs
|
|
6
|
+
* to be preloaded before the pipeline is created.
|
|
7
|
+
*/
|
|
8
|
+
declare class SharedResourceManager {
|
|
9
|
+
private modelSessions;
|
|
10
|
+
private worker?;
|
|
11
|
+
private workerUrl?;
|
|
12
|
+
private resolvedUriCache;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the worker using the provided configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param config - The configuration object.
|
|
17
|
+
* @returns A promise that resolves when the worker is initialized.
|
|
18
|
+
*/
|
|
19
|
+
initializeWorker(config: WorkerConfig): Promise<Worker>;
|
|
20
|
+
/**
|
|
21
|
+
* Terminate the worker.
|
|
22
|
+
*/
|
|
23
|
+
terminateWorker(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Load the model using the provided configuration. This gets called by the worker when using
|
|
26
|
+
* the worker generator.
|
|
27
|
+
*
|
|
28
|
+
* @param config - The configuration object.
|
|
29
|
+
* @returns A promise that resolves when the model is preloaded.
|
|
30
|
+
*/
|
|
31
|
+
loadModel(config: PreloadConfig): Promise<ort.InferenceSession>;
|
|
32
|
+
/**
|
|
33
|
+
* Preload the worker using the provided configuration.
|
|
34
|
+
*
|
|
35
|
+
* @param config - The configuration object.
|
|
36
|
+
* @returns A promise that resolves when the worker is preloaded.
|
|
37
|
+
*/
|
|
38
|
+
preloadWorker(config: PreloadConfig): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Warmup the model session with a dummy input to avoid latency when running the model for the first time.
|
|
41
|
+
*
|
|
42
|
+
* @param {ort.InferenceSession} session The model session.
|
|
43
|
+
* @param {ResolutionConfig} inputSize The input size of the model.
|
|
44
|
+
* @param {number} inputChannels The number of input channels (e.g., RGB is 3).
|
|
45
|
+
* @param {ort.Tensor.Type} inputType The input tensor type.
|
|
46
|
+
* @returns {Promise<void>} A promise that resolves when the model is warmed up.
|
|
47
|
+
* @example
|
|
48
|
+
* await warmupModel(session, inputSize, inputChannels, inputType);
|
|
49
|
+
*/
|
|
50
|
+
warmupModel(session: ort.InferenceSession, inputSize?: ResolutionConfig, inputChannels?: number, inputType?: ort.Tensor.Type): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Get the model session for the provided model URL.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} modelUrl The model URL.
|
|
55
|
+
* @returns {ort.InferenceSession} The model session.
|
|
56
|
+
* @example
|
|
57
|
+
* const session = getModelSession(modelUrl);
|
|
58
|
+
*/
|
|
59
|
+
getModelSession(modelUrl: string): ort.InferenceSession;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the full URL for a given asset. Non-file URIs are treated as paths
|
|
62
|
+
* and resolved using the `toAbsoluteURI` method.
|
|
63
|
+
*
|
|
64
|
+
* @param config - The preload configuration.
|
|
65
|
+
* @param assetUri - The asset URI from the config.
|
|
66
|
+
* @returns The resolved full URL.
|
|
67
|
+
*/
|
|
68
|
+
/**
|
|
69
|
+
* Resolves the full URL for a given asset. Non-file URIs are treated as paths and resolved
|
|
70
|
+
* using the `toAbsoluteURI` method. If the assetUri is already resolved, or if it's found in
|
|
71
|
+
* cache, it will be returned directly. If an assetUrlResolver function is provided in the
|
|
72
|
+
* configuration, it will be used to resolve the URL if the assetUri is not fully qualified,
|
|
73
|
+
* a blob URL, or in the cache.
|
|
74
|
+
*
|
|
75
|
+
* @param config - The preload configuration.
|
|
76
|
+
* @param assetUri - The asset URI from the config.
|
|
77
|
+
* @returns The resolved full URL.
|
|
78
|
+
*/
|
|
79
|
+
resolveUri(config: PreloadConfig, assetUri?: string): Promise<string>;
|
|
80
|
+
getWorker(): Worker | undefined;
|
|
81
|
+
getWorkerUrl(): string | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* Prepare the worker configuration by resolving the final URLs and paths to send to the
|
|
84
|
+
* worker. This is necessary because we can't send functions to the worker. We also need to
|
|
85
|
+
* remove the assetUrlResolver function from the configuration.
|
|
86
|
+
*
|
|
87
|
+
* @param config - The preload configuration.
|
|
88
|
+
* @returns The worker configuration.
|
|
89
|
+
*/
|
|
90
|
+
prepareWorkerConfig(config: PreloadConfig): Promise<any>;
|
|
91
|
+
}
|
|
92
|
+
export declare const sharedResourceManager: SharedResourceManager;
|
|
93
|
+
export {};
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
export declare enum InterpolationMethod {
|
|
2
|
-
Nearest = "nearest"
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Resizes an image from the source dimensions to target dimensions.
|
|
6
|
-
*
|
|
7
|
-
* @param {Uint8ClampedArray} imageData The source image data in Uint8ClampedArray format.
|
|
8
|
-
* @param {number} srcWidth The width of the source image.
|
|
9
|
-
* @param {number} srcHeight The height of the source image.
|
|
10
|
-
* @param {number} targetWidth The width of the target image.
|
|
11
|
-
* @param {number} targetHeight The height of the target image.
|
|
12
|
-
*
|
|
13
|
-
* @returns {Uint8ClampedArray} The target image data in Uint8ClampedArray format.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* const targetData = resizeImage(sourceData, 800, 600, 400, 300);
|
|
17
|
-
*
|
|
18
|
-
* @note The function uses a "nearest neighbor" algorithm for resizing,
|
|
19
|
-
* which is fast but might not provide the best quality for all images.
|
|
20
|
-
*/
|
|
21
|
-
export declare const resizeImage: (imageData: Uint8ClampedArray, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number) => Uint8ClampedArray;
|
|
22
|
-
/**
|
|
23
|
-
* Upsamples an image using the bilinear interpolation method. The input image is expected to be in
|
|
24
|
-
* Float32Array format. The output image is in Uint8ClampedArray format. The input image is expected
|
|
25
|
-
* to be in the [0, 1] range. The output image is in the [0, 255] range.
|
|
26
|
-
*
|
|
27
|
-
* @param {Float32Array} input The input image data in Float32Array format.
|
|
28
|
-
* @param {number} srcWidth The width of the source image.
|
|
29
|
-
* @param {number} srcHeight The height of the source image.
|
|
30
|
-
* @param {number} targetWidth The width of the target image.
|
|
31
|
-
* @param {number} targetHeight The height of the target image.
|
|
32
|
-
*
|
|
33
|
-
* @returns {Uint8ClampedArray} The upsampled image data in Uint8ClampedArray format.
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
export declare function bilinearUpsample(input: Float32Array, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number): Uint8ClampedArray;
|
|
37
|
-
/**
|
|
38
|
-
* Upsamples an image using the Lanczos3 interpolation method. The input image is expected to be in
|
|
39
|
-
* Float32Array format. The output image is in Uint8ClampedArray format. The input image is expected
|
|
40
|
-
* to be in the [0, 1] range. The output image is in the [0, 255] range.
|
|
41
|
-
*
|
|
42
|
-
* @param {Float32Array} input The input image data in Float32Array format.
|
|
43
|
-
* @param {number} srcWidth The width of the source image.
|
|
44
|
-
* @param {number} srcHeight The height of the source image.
|
|
45
|
-
* @param {number} targetWidth The width of the target image.
|
|
46
|
-
* @param {number} targetHeight The height of the target image.
|
|
47
|
-
*
|
|
48
|
-
* @returns {Uint8ClampedArray} The upsampled image data in Uint8ClampedArray format.
|
|
49
|
-
*/
|
|
50
|
-
export declare function lanczos3Upsample(input: Float32Array, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number): Uint8ClampedArray;
|
|
51
|
-
export declare const toAbsoluteURI: (relativeURL: string, baseURL?: string) => string;
|
|
52
|
-
export declare function compileShader(gl: WebGL2RenderingContext, shader_type: number, source: string): WebGLShader;
|
|
53
|
-
export declare function linkProgram(gl: WebGL2RenderingContext, vertex_shader: WebGLShader, fragment_shader: WebGLShader): WebGLProgram;
|
|
54
|
-
/**
|
|
55
|
-
* Determines if a URI is already resolved.
|
|
56
|
-
* A resolved URI is either:
|
|
57
|
-
* - A blob URL (starts with 'blob:')
|
|
58
|
-
* - A fully qualified URL (e.g., http:// or https://)
|
|
59
|
-
*
|
|
60
|
-
* @param uri - The URI to check.
|
|
61
|
-
* @returns Whether the URI is already resolved.
|
|
62
|
-
*/
|
|
63
|
-
export declare function isResolvedUri(uri: string): boolean;
|
|
64
|
-
export declare function loadAndCacheFile(fileUrl: string): Promise<ArrayBufferLike | Uint8Array>;
|
|
1
|
+
export declare enum InterpolationMethod {
|
|
2
|
+
Nearest = "nearest"
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Resizes an image from the source dimensions to target dimensions.
|
|
6
|
+
*
|
|
7
|
+
* @param {Uint8ClampedArray} imageData The source image data in Uint8ClampedArray format.
|
|
8
|
+
* @param {number} srcWidth The width of the source image.
|
|
9
|
+
* @param {number} srcHeight The height of the source image.
|
|
10
|
+
* @param {number} targetWidth The width of the target image.
|
|
11
|
+
* @param {number} targetHeight The height of the target image.
|
|
12
|
+
*
|
|
13
|
+
* @returns {Uint8ClampedArray} The target image data in Uint8ClampedArray format.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const targetData = resizeImage(sourceData, 800, 600, 400, 300);
|
|
17
|
+
*
|
|
18
|
+
* @note The function uses a "nearest neighbor" algorithm for resizing,
|
|
19
|
+
* which is fast but might not provide the best quality for all images.
|
|
20
|
+
*/
|
|
21
|
+
export declare const resizeImage: (imageData: Uint8ClampedArray, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number) => Uint8ClampedArray;
|
|
22
|
+
/**
|
|
23
|
+
* Upsamples an image using the bilinear interpolation method. The input image is expected to be in
|
|
24
|
+
* Float32Array format. The output image is in Uint8ClampedArray format. The input image is expected
|
|
25
|
+
* to be in the [0, 1] range. The output image is in the [0, 255] range.
|
|
26
|
+
*
|
|
27
|
+
* @param {Float32Array} input The input image data in Float32Array format.
|
|
28
|
+
* @param {number} srcWidth The width of the source image.
|
|
29
|
+
* @param {number} srcHeight The height of the source image.
|
|
30
|
+
* @param {number} targetWidth The width of the target image.
|
|
31
|
+
* @param {number} targetHeight The height of the target image.
|
|
32
|
+
*
|
|
33
|
+
* @returns {Uint8ClampedArray} The upsampled image data in Uint8ClampedArray format.
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export declare function bilinearUpsample(input: Float32Array, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number): Uint8ClampedArray;
|
|
37
|
+
/**
|
|
38
|
+
* Upsamples an image using the Lanczos3 interpolation method. The input image is expected to be in
|
|
39
|
+
* Float32Array format. The output image is in Uint8ClampedArray format. The input image is expected
|
|
40
|
+
* to be in the [0, 1] range. The output image is in the [0, 255] range.
|
|
41
|
+
*
|
|
42
|
+
* @param {Float32Array} input The input image data in Float32Array format.
|
|
43
|
+
* @param {number} srcWidth The width of the source image.
|
|
44
|
+
* @param {number} srcHeight The height of the source image.
|
|
45
|
+
* @param {number} targetWidth The width of the target image.
|
|
46
|
+
* @param {number} targetHeight The height of the target image.
|
|
47
|
+
*
|
|
48
|
+
* @returns {Uint8ClampedArray} The upsampled image data in Uint8ClampedArray format.
|
|
49
|
+
*/
|
|
50
|
+
export declare function lanczos3Upsample(input: Float32Array, srcWidth: number, srcHeight: number, targetWidth: number, targetHeight: number): Uint8ClampedArray;
|
|
51
|
+
export declare const toAbsoluteURI: (relativeURL: string, baseURL?: string) => string;
|
|
52
|
+
export declare function compileShader(gl: WebGL2RenderingContext, shader_type: number, source: string): WebGLShader;
|
|
53
|
+
export declare function linkProgram(gl: WebGL2RenderingContext, vertex_shader: WebGLShader, fragment_shader: WebGLShader): WebGLProgram;
|
|
54
|
+
/**
|
|
55
|
+
* Determines if a URI is already resolved.
|
|
56
|
+
* A resolved URI is either:
|
|
57
|
+
* - A blob URL (starts with 'blob:')
|
|
58
|
+
* - A fully qualified URL (e.g., http:// or https://)
|
|
59
|
+
*
|
|
60
|
+
* @param uri - The URI to check.
|
|
61
|
+
* @returns Whether the URI is already resolved.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isResolvedUri(uri: string): boolean;
|
|
64
|
+
export declare function loadAndCacheFile(fileUrl: string): Promise<ArrayBufferLike | Uint8Array>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "5.4.
|
|
1
|
+
export declare const LIB_VERSION = "5.4.2";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/lib/version.ts"],"sourcesContent":["export const LIB_VERSION = '5.4.
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/lib/version.ts"],"sourcesContent":["export const LIB_VERSION = '5.4.2';\n"],"names":["LIB_VERSION"],"mappings":"AAAO,MAAMA,IAAc;"}
|
|
Binary file
|