ImageEmbedder class

Performs embedding extraction on images.

Signature:

export declare class ImageEmbedder extends VisionTaskRunner 

Extends: VisionTaskRunner

Methods

Method Modifiers Description
cosineSimilarity(u, v) static Utility function to compute cosine similarity[1] between two Embedding objects.[1]: https://en.wikipedia.org/wiki/Cosine_similarity
createFromModelBuffer(wasmFileset, modelAssetBuffer) static Initializes the Wasm runtime and creates a new image embedder based on the provided model asset buffer.
createFromModelPath(wasmFileset, modelAssetPath) static Initializes the Wasm runtime and creates a new image embedder based on the path to the model asset.
createFromOptions(wasmFileset, imageEmbedderOptions) static Initializes the Wasm runtime and creates a new image embedder from the provided options.
embed(image, imageProcessingOptions) Performs embedding extraction on the provided single image and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode image.
embedForVideo(imageFrame, timestamp, imageProcessingOptions) Performs embedding extraction on the provided video frame and waits synchronously for the response. Only use this method when the ImageEmbedder is created with running mode video.
setOptions(options) Sets new options for the image embedder.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.

ImageEmbedder.cosineSimilarity()

Utility function to compute cosine similarity[1] between two Embedding objects.

[1]: https://en.wikipedia.org/wiki/Cosine_similarity

Signature:

static cosineSimilarity(u: Embedding, v: Embedding): number;

Parameters

Parameter Type Description
u Embedding
v