Performs face stylization on images.
Signature:
export declare class FaceStylizer extends VisionTaskRunner
Extends: VisionTaskRunner
Methods
Method | Modifiers | Description |
---|---|---|
createFromModelBuffer(wasmFileset, modelAssetBuffer) | static |
Initializes the Wasm runtime and creates a new Face Stylizer based on the provided model asset buffer. |
createFromModelPath(wasmFileset, modelAssetPath) | static |
Initializes the Wasm runtime and creates a new Face Stylizer based on the path to the model asset. |
createFromOptions(wasmFileset, faceStylizerOptions) | static |
Initializes the Wasm runtime and creates a new Face Stylizer from the provided options. |
setOptions(options) | Sets new options for the Face Stylizer.Calling setOptions() with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined . |
|
stylize(image, callback) | Performs face stylization on the provided single image and invokes the callback with result. The method returns synchronously once the callback returns. Only use this method when the FaceStylizer is created with the image running mode. | |
stylize(image, imageProcessingOptions, callback) | Performs face stylization on the provided single image and invokes the callback with result. The method returns synchronously once the callback returns. Only use this method when the FaceStylizer is created with the image running mode.The 'imageProcessingOptions' parameter can be used to specify one or all of: - the rotation to apply to the image before performing stylization, by setting its 'rotationDegrees' property. - the region-of-interest on which to perform stylization, by setting its 'regionOfInterest' property. If not specified, the full image is used. If both are specified, the crop around the region-of-interest is extracted first, then the specified rotation is applied to the crop. | |
stylize(image) | Performs face stylization on the provided single image and returns the result. This method creates a copy of the resulting image and should not be used in high-throughput applications. Only use this method when the FaceStylizer is created with the image running mode. | |
stylize(image, imageProcessingOptions) | Performs face stylization on the provided single image and returns the result. This method creates a copy of the resulting image and should not be used in high-throughput applications. Only use this method when the FaceStylizer is created with the image running mode.The 'imageProcessingOptions' parameter can be used to specify one or all of: - the rotation to apply to the image before performing stylization, by setting its 'rotationDegrees' property. - the region-of-interest on which to perform stylization, by setting its 'regionOfInterest' property. If not specified, the full image is used. If both are specified, the crop around the region-of-interest is extracted first, then the specified rotation is applied to the crop. |
FaceStylizer.createFromModelBuffer()
Initializes the Wasm runtime and creates a new Face Stylizer based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<FaceStylizer>;
Parameters
Parameter | Type | Description |
---|---|---|
wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
modelAssetBuffer | Uint8Array | A binary representation of the model. |
Returns:
Promise<FaceStylizer>
FaceStylizer.createFromModelPath()
Initializes the Wasm runtime and creates a new Face Stylizer based on the path to the model asset.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<FaceStylizer>;
Parameters
Parameter | Type | Description |
---|---|---|
wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
modelAssetPath | string | The path to the model asset. |
Returns:
Promise<FaceStylizer>
FaceStylizer.createFromOptions()
Initializes the Wasm runtime and creates a new Face Stylizer from the provided options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, faceStylizerOptions: FaceStylizerOptions): Promise<FaceStylizer>;
Parameters
Parameter | Type | Description |
---|---|---|
wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
faceStylizerOptions | FaceStylizerOptions | The options for the Face Stylizer. Note that either a path to the model asset or a model buffer needs to be provided (via baseOptions ). |
Returns:
Promise<FaceStylizer>
FaceStylizer.setOptions()
Sets new options for the Face Stylizer.
Calling setOptions()
with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined
.
Signature:
setOptions(options: FaceStylizerOptions): Promise<void>;
Parameters
Parameter | Type | Description |
---|---|---|
options | FaceStylizerOptions | The options for the Face Stylizer. |
Returns:
Promise<void>
FaceStylizer.stylize()
Performs face stylization on the provided single image and invokes the callback with result. The method returns synchronously once the callback returns. Only use this method when the FaceStylizer is created with the image running mode.
Signature:
stylize(image: ImageSource, callback: FaceStylizerCallback): void;
Parameters
Parameter | Type | Description |
---|---|---|
image | ImageSource | An image to process. |
callback | FaceStylizerCallback | The callback that is invoked with the stylized image or null if no face was detected. The lifetime of the returned data is only guaranteed for the duration of the callback. |
Returns:
void
FaceStylizer.stylize()
Performs face stylization on the provided single image and invokes the callback with result. The method returns synchronously once the callback returns. Only use this method when the FaceStylizer is created with the image running mode.
The 'imageProcessingOptions' parameter can be used to specify one or all of: - the rotation to apply to the image before performing stylization, by setting its 'rotationDegrees' property. - the region-of-interest on which to perform stylization, by setting its 'regionOfInterest' property. If not specified, the full image is used. If both are specified, the crop around the region-of-interest is extracted first, then the specified rotation is applied to the crop.
Signature:
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions, callback: FaceStylizerCallback): void;
Parameters
Parameter | Type | Description |
---|---|---|
image | ImageSource | An image to process. |
imageProcessingOptions | ImageProcessingOptions | the ImageProcessingOptions specifying how to process the input image before running inference. |
callback | FaceStylizerCallback | The callback that is invoked with the stylized image or null if no face was detected. The lifetime of the returned data is only guaranteed for the duration of the callback. |
Returns:
void
FaceStylizer.stylize()
Performs face stylization on the provided single image and returns the result. This method creates a copy of the resulting image and should not be used in high-throughput applications. Only use this method when the FaceStylizer is created with the image running mode.
Signature:
stylize(image: ImageSource): MPImage | null;
Parameters
Parameter | Type | Description |
---|---|---|
image | ImageSource | An image to process. A stylized face or null if no face was detected. The result is copied to avoid lifetime issues. |
Returns:
MPImage | null
FaceStylizer.stylize()
Performs face stylization on the provided single image and returns the result. This method creates a copy of the resulting image and should not be used in high-throughput applications. Only use this method when the FaceStylizer is created with the image running mode.
The 'imageProcessingOptions' parameter can be used to specify one or all of: - the rotation to apply to the image before performing stylization, by setting its 'rotationDegrees' property. - the region-of-interest on which to perform stylization, by setting its 'regionOfInterest' property. If not specified, the full image is used. If both are specified, the crop around the region-of-interest is extracted first, then the specified rotation is applied to the crop.
Signature:
stylize(image: ImageSource, imageProcessingOptions: ImageProcessingOptions): MPImage | null;
Parameters
Parameter | Type | Description |
---|---|---|
image | ImageSource | An image to process. |
imageProcessingOptions | ImageProcessingOptions | the ImageProcessingOptions specifying how to process the input image before running inference. A stylized face or null if no face was detected. The result is copied to avoid lifetime issues. |
Returns:
MPImage | null