ImageEmbedder.ImageEmbedderOptions.Builder

public abstract class ImageEmbedder.ImageEmbedderOptions.Builder


Builder for ImageEmbedderOptions.

Summary

Public constructors

Public methods

final ImageEmbedder.ImageEmbedderOptions

Validates and builds the ImageEmbedderOptions instance. *

abstract ImageEmbedder.ImageEmbedderOptions.Builder

Sets the BaseOptions for the image embedder task.

abstract ImageEmbedder.ImageEmbedderOptions.Builder

Sets an optional ErrorListener.

abstract ImageEmbedder.ImageEmbedderOptions.Builder
setL2Normalize(boolean l2Normalize)

Sets whether L2 normalization should be performed on the returned embeddings.

abstract ImageEmbedder.ImageEmbedderOptions.Builder
setQuantize(boolean quantize)

Sets whether the returned embedding should be quantized to bytes via scalar quantization.

abstract ImageEmbedder.ImageEmbedderOptions.Builder

Sets the ResultListener to receive the embedding results asynchronously, when the image embedder is in the live stream mode.

abstract ImageEmbedder.ImageEmbedderOptions.Builder

Sets the RunningMode for the image embedder task.

Public constructors

Builder

public Builder()

Public methods

build

public final ImageEmbedder.ImageEmbedderOptions build()

Validates and builds the ImageEmbedderOptions instance. *

Throws
java.lang.IllegalArgumentException

if the result listener and the running mode are not properly configured. The result listener should only be set when the image embedder is in the live stream mode.

setBaseOptions

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setBaseOptions(BaseOptions baseOptions)

Sets the BaseOptions for the image embedder task.

setErrorListener

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setErrorListener(ErrorListener errorListener)

Sets an optional ErrorListener.

setL2Normalize

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setL2Normalize(boolean l2Normalize)

Sets whether L2 normalization should be performed on the returned embeddings. Use this option only if the model does not already contain a native L2_NORMALIZATION TF Lite Op. In most cases, this is already the case and L2 norm is thus achieved through TF Lite inference.

False by default.

setQuantize

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setQuantize(boolean quantize)

Sets whether the returned embedding should be quantized to bytes via scalar quantization. Embeddings are implicitly assumed to be unit-norm and therefore any dimensions is guaranteed to have value in [-1.0, 1.0]. Use setL2Normalize if this is not the case.

False by default.

setResultListener

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setResultListener(
    OutputHandler.ResultListener<ImageEmbedderResult, MPImage> resultListener
)

Sets the ResultListener to receive the embedding results asynchronously, when the image embedder is in the live stream mode.

setRunningMode

public abstract ImageEmbedder.ImageEmbedderOptions.Builder setRunningMode(RunningMode runningMode)

Sets the RunningMode for the image embedder task. Default to the image mode. Image embedder has three modes:

  • IMAGE: The mode for performing embedding extraction on single image inputs.
  • VIDEO: The mode for performing embedding extraction on the decoded frames of a video.
  • LIVE_STREAM: The mode for for performing embedding extraction on a live stream of input data, such as from camera. In this mode, setResultListener must be called to set up a listener to receive the embedding results asynchronously.