@vonage/ml-transformers 4.0.1 → 4.2.0

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.
Files changed (37) hide show
  1. package/dist/docs/assets/search.js +1 -1
  2. package/dist/docs/classes/BackgroundTransformer.html +1 -0
  3. package/dist/docs/classes/MediapipeHelper.html +1 -1
  4. package/dist/docs/classes/VonageMediaProcessor.html +1 -1
  5. package/dist/docs/enums/BlurRadius.html +1 -1
  6. package/dist/docs/enums/ErrorFunction.html +1 -1
  7. package/dist/docs/enums/PipelineInfoData.html +1 -1
  8. package/dist/docs/enums/SelfieSegmentationType.html +1 -1
  9. package/dist/docs/enums/WarningType.html +1 -1
  10. package/dist/docs/index.html +1 -1
  11. package/dist/docs/interfaces/FaceDetectionOptions.html +1 -1
  12. package/dist/docs/interfaces/FaceDetectionResults.html +1 -1
  13. package/dist/docs/interfaces/FaceMeshOptions.html +1 -1
  14. package/dist/docs/interfaces/FaceMeshResults.html +1 -1
  15. package/dist/docs/interfaces/FeatureSupport.html +7 -0
  16. package/dist/docs/interfaces/HandsOptions.html +1 -1
  17. package/dist/docs/interfaces/HandsResults.html +1 -1
  18. package/dist/docs/interfaces/HolisticOptions.html +1 -1
  19. package/dist/docs/interfaces/HolisticResults.html +1 -1
  20. package/dist/docs/interfaces/ObjectronOptions.html +1 -1
  21. package/dist/docs/interfaces/ObjectronResults.html +1 -1
  22. package/dist/docs/interfaces/PoseOptions.html +1 -1
  23. package/dist/docs/interfaces/PoseResults.html +1 -1
  24. package/dist/docs/interfaces/SelfieSegmentationOptions.html +1 -1
  25. package/dist/docs/interfaces/SelfieSegmentationResults.html +1 -1
  26. package/dist/docs/interfaces/SupportedBrowserFeatures.html +11 -0
  27. package/dist/docs/modules.html +8 -5
  28. package/dist/ml-transformers.es.js +20573 -20543
  29. package/dist/ml-transformers.min.js +4 -0
  30. package/dist/ml-transformers.static.js +29539 -0
  31. package/dist/ml-transformers.umd.js +50 -50
  32. package/dist/types/main.d.ts +5 -4
  33. package/dist/types/src/types.d.ts +34 -0
  34. package/dist/types/src/utils/support.d.ts +9 -3
  35. package/dist/types/src/wasm/selfie-segmentation/loader.d.ts +1 -0
  36. package/dist/types/src/wasm/selfie-segmentation/wrapper.d.ts +2 -0
  37. package/package.json +4 -2
@@ -1,8 +1,9 @@
1
1
  import { WarningType, ErrorFunction, PipelineInfoData } from "@vonage/media-processor";
2
- import { BlurRadius, BackgroundBlurConfig, VirtualBackgroundConfig, AssetBackgroundConfig, VideoBackgroundConfig, MediaProcessorBaseConfig, SilhouetteBlurConfig, MediapipeConfig, MediaPipeResults, MediaPipeResultsListener, MediaPipeModelType, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, PoseResults, PoseOptions, SelfieSegmentationResults, SelfieSegmentationOptions, MediaPipeModelConfig } from "./src/types";
3
- import { isSupported } from "./src/utils/support";
2
+ import { BlurRadius, BackgroundBlurConfig, VirtualBackgroundConfig, AssetBackgroundConfig, VideoBackgroundConfig, MediaProcessorBaseConfig, SilhouetteBlurConfig, MediapipeConfig, MediaPipeResults, MediaPipeResultsListener, MediaPipeModelType, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, PoseResults, PoseOptions, SelfieSegmentationResults, SelfieSegmentationOptions, MediaPipeModelConfig, SupportedBrowserFeatures, FeatureSupport } from "./src/types";
3
+ import { isSupported, getSupportedBrowserFeatures } from "./src/utils/support";
4
4
  import { MediapipeHelper } from "./src/utils/mediapipe";
5
5
  import { VonageMediaProcessor } from "./src/facades/vonage-media-processor";
6
+ import { BackgroundTransformer } from "./src/transformers/background-transformer";
6
7
  import VonageSelfieSegmentation from "./libs/selfie-segmentation-helper";
7
8
  /**
8
9
  * MediaPipe Selfie Segmentation static metadata.
@@ -146,5 +147,5 @@ declare type MediaProcessorConfig = MediaProcessorBaseConfig & BackgroundOptions
146
147
  */
147
148
  export declare function createVonageMediaProcessor(config: MediaProcessorConfig): Promise<VonageMediaProcessor>;
148
149
  export type { EventDataMap, WarnData, ErrorData, EventMetaData, DropInfo, } from "@vonage/media-processor";
149
- export type { MediaProcessorBaseConfig, BackgroundBlurConfig, VirtualBackgroundConfig, VideoBackgroundConfig, AssetBackgroundConfig, SilhouetteBlurConfig, MediaProcessorConfig, BackgroundOptions, MediapipeConfig, MediaPipeResults, MediaPipeModelType, MediaPipeResultsListener, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationOptions, SelfieSegmentationResults, PoseResults, PoseOptions, MediaPipeModelConfig, };
150
- export { VonageMediaProcessor, BlurRadius, isSupported, MediapipeHelper, getVonageSelfieSegmentation, getVonageFaceDetection, getVonageFaceMash, getVonageHands, getVonageHolistic, getVonageObjectron, getVonagePose, WarningType, PipelineInfoData, ErrorFunction, };
150
+ export type { MediaProcessorBaseConfig, BackgroundBlurConfig, VirtualBackgroundConfig, VideoBackgroundConfig, AssetBackgroundConfig, SilhouetteBlurConfig, MediaProcessorConfig, BackgroundOptions, MediapipeConfig, MediaPipeResults, MediaPipeModelType, MediaPipeResultsListener, FaceDetectionResults, FaceDetectionOptions, FaceMeshResults, FaceMeshOptions, HandsResults, HandsOptions, HolisticResults, HolisticOptions, ObjectronResults, ObjectronOptions, SelfieSegmentationOptions, SelfieSegmentationResults, PoseResults, PoseOptions, MediaPipeModelConfig, SupportedBrowserFeatures, FeatureSupport, };
151
+ export { VonageMediaProcessor, BlurRadius, isSupported, getSupportedBrowserFeatures, MediapipeHelper, getVonageSelfieSegmentation, getVonageFaceDetection, getVonageFaceMash, getVonageHands, getVonageHolistic, getVonageObjectron, getVonagePose, WarningType, PipelineInfoData, ErrorFunction, BackgroundTransformer, };
@@ -157,3 +157,37 @@ export declare type TextureSource = string | number[] | ArrayBufferView | TexIma
157
157
  export declare type UniformDataMap = {
158
158
  [key: string]: number | number[] | WebGLTexture;
159
159
  };
160
+ /**
161
+ * Feature support detail
162
+ */
163
+ export interface FeatureSupport {
164
+ /**
165
+ * Is the feature supported
166
+ */
167
+ supported: boolean;
168
+ /**
169
+ * Readable message explaining the feature is not supported
170
+ */
171
+ message?: string;
172
+ }
173
+ /**
174
+ * Features supported by the browser
175
+ */
176
+ export interface SupportedBrowserFeatures {
177
+ /**
178
+ * Web assembly support, required to use ml-transformer
179
+ */
180
+ wasm: FeatureSupport;
181
+ /**
182
+ * Simd support, required to use ml-transformer
183
+ */
184
+ simd: FeatureSupport;
185
+ /**
186
+ * Insertable stream support, required to use ml-transformer
187
+ */
188
+ insertableStreams: FeatureSupport;
189
+ /**
190
+ * GPU processing support, optional
191
+ */
192
+ gpu: FeatureSupport;
193
+ }
@@ -1,6 +1,12 @@
1
+ import { SupportedBrowserFeatures } from "../types";
1
2
  /**
2
3
  * Check if the current browser is officially supported by the library.
3
- * **If this function is rejected the library might be able to run but the performance is unknown**
4
- * @returns
4
+ *
5
+ * @returns The promise will resolve or reject depending whether the browser is supported or not.
5
6
  */
6
- export declare function isSupported(): Promise<void>;
7
+ export declare function isSupported(wasmAssetUriPath?: string, tfliteAssetUriPath?: string): Promise<void>;
8
+ /**
9
+ * Detect which features is available in the browser.
10
+ * @returns Supported features by the browser
11
+ */
12
+ export declare function getSupportedBrowserFeatures(wasmAssetUriPath?: string, tfliteAssetUriPath?: string): Promise<SupportedBrowserFeatures>;
@@ -11,6 +11,7 @@ export interface TFLite extends EmscriptenModule {
11
11
  _getOutputChannelCount(): number;
12
12
  _loadModel(bufferSize: number): number;
13
13
  _runInference(): number;
14
+ _isGPUEnabled(): boolean;
14
15
  }
15
16
  export declare class VonageTFLiteInfo {
16
17
  selectedTFLite: TFLite;
@@ -7,9 +7,11 @@ export declare class SelfieSegmentation {
7
7
  private infos?;
8
8
  private mask?;
9
9
  init(wasmAssetUriPath?: string, tfliteAssetUriPath?: string): Promise<void>;
10
+ initWasm(wasmAssetUriPath?: string, tfliteAssetUriPath?: string): Promise<void>;
10
11
  getOutputDimensions(): {
11
12
  width: number;
12
13
  height: number;
13
14
  };
14
15
  process(input: ImageBitmap): Promise<ImageBitmap | void>;
16
+ isGpuSupported(): boolean;
15
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/ml-transformers",
3
- "version": "4.0.1",
3
+ "version": "4.2.0",
4
4
  "author": "Guy Mininberg <guy.mininberg@vonage.com>",
5
5
  "contributors": [
6
6
  "Guy Mininberg <guy.mininberg@vonage.com>",
@@ -23,8 +23,9 @@
23
23
  "nexmo"
24
24
  ],
25
25
  "scripts": {
26
- "build": "npm-run-all build:js doc",
26
+ "build": "npm-run-all build:js build:static doc",
27
27
  "build:js": "tsc && vite build && tsc --declaration --emitDeclarationOnly --outDir dist/types",
28
+ "build:static": "node ./scripts/build-static.js && minify ./dist/ml-transformers.static.js > ./dist/ml-transformers.min.js ",
28
29
  "doc": "typedoc --excludePrivate --excludeProtected --disableSources --out dist/docs lib/main.ts",
29
30
  "dev": "vite",
30
31
  "prettier": "prettier --write ./lib/src/**/*.ts",
@@ -64,6 +65,7 @@
64
65
  },
65
66
  "devDependencies": {
66
67
  "@tsconfig/node12": "^1.0.1",
68
+ "minify": "^9.1.0",
67
69
  "npm-run-all": "^4.1.5",
68
70
  "typedoc": "^0.22.12",
69
71
  "typescript": "^4.5.4",