ImageClassifier.ImageClassifierOptions.Builder

public static abstract class ImageClassifier.ImageClassifierOptions.Builder

Public Constructors

Public Methods

final ImageClassifier.ImageClassifierOptions
build()
Validates and builds the ImageClassifier.ImageClassifierOptions instance.
abstract ImageClassifier.ImageClassifierOptions.Builder
setBaseOptions(BaseOptions baseOptions)
Sets the BaseOptions for the image classifier task.
abstract ImageClassifier.ImageClassifierOptions.Builder
setCategoryAllowlist(List<String> categoryAllowlist)
Sets the optional allowlist of category names.
abstract ImageClassifier.ImageClassifierOptions.Builder
setCategoryDenylist(List<String> categoryDenylist)
Sets the optional denylist of category names.
abstract ImageClassifier.ImageClassifierOptions.Builder
setDisplayNamesLocale(String locale)
Sets the optional locale to use for display names specified through the TFLite Model Metadata, if any.
abstract ImageClassifier.ImageClassifierOptions.Builder
setErrorListener(ErrorListener errorListener)
Sets an optional ErrorListener.
abstract ImageClassifier.ImageClassifierOptions.Builder
setMaxResults(Integer maxResults)
Sets the optional maximum number of top-scored classification results to return.
abstract ImageClassifier.ImageClassifierOptions.Builder
setResultListener(ResultListener<ImageClassifierResultMPImage> resultListener)
Sets the OutputHandler.ResultListener to receive the classification results asynchronously when the image classifier is in the live stream mode.
abstract ImageClassifier.ImageClassifierOptions.Builder
setRunningMode(RunningMode runningMode)
Sets the RunningMode for the image classifier task.
abstract ImageClassifier.ImageClassifierOptions.Builder
setScoreThreshold(Float scoreThreshold)
Sets the optional score threshold.

Inherited Methods

Public Constructors

public Builder ()

Public Methods

public final ImageClassifier.ImageClassifierOptions build ()

Validates and builds the ImageClassifier.ImageClassifierOptions instance. *

Throws
IllegalArgumentException if any of the set options are invalid.

public abstract ImageClassifier.ImageClassifierOptions.Builder setBaseOptions (BaseOptions baseOptions)

Sets the BaseOptions for the image classifier task.

Parameters
baseOptions

public abstract ImageClassifier.ImageClassifierOptions.Builder setCategoryAllowlist (List<String> categoryAllowlist)

Sets the optional allowlist of category names.

If non-empty, detection results whose category name is not in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryDenylist.

Parameters
categoryAllowlist

public abstract ImageClassifier.ImageClassifierOptions.Builder setCategoryDenylist (List<String> categoryDenylist)

Sets the optional denylist of category names.

If non-empty, detection results whose category name is in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryAllowlist.

Parameters
categoryDenylist

public abstract ImageClassifier.ImageClassifierOptions.Builder setDisplayNamesLocale (String locale)

Sets the optional locale to use for display names specified through the TFLite Model Metadata, if any.

Parameters
locale

public abstract ImageClassifier.ImageClassifierOptions.Builder setErrorListener (ErrorListener errorListener)

Sets an optional ErrorListener.

Parameters
errorListener

public abstract ImageClassifier.ImageClassifierOptions.Builder setMaxResults (Integer maxResults)

Sets the optional maximum number of top-scored classification results to return.

If not set, all available results are returned. If set, must be > 0.

Parameters
maxResults

public abstract ImageClassifier.ImageClassifierOptions.Builder setResultListener (ResultListener<ImageClassifierResultMPImage> resultListener)

Sets the OutputHandler.ResultListener to receive the classification results asynchronously when the image classifier is in the live stream mode.

Parameters
resultListener

public abstract ImageClassifier.ImageClassifierOptions.Builder setRunningMode (RunningMode runningMode)

Sets the RunningMode for the image classifier task. Default to the image mode. Image cla