Builder for ImageClassifier.ImageClassifierOptions.
Public Constructors
|
Builder()
|
Public Methods
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<ImageClassifierResult, MPImage> 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 classifier has three modes:
- IMAGE: The mode for performing classification on single image inputs.
- VIDEO: The mode for performing classification on the decoded frames of a video.
- LIVE_STREAM: The mode for for performing classification on a live stream of input
data, such as from camera. In this mode,
setResultListenermust be called to set up a listener to receive the classification results asynchronously.
Parameters
| runningMode |
|---|
public abstract ImageClassifier.ImageClassifierOptions.Builder setScoreThreshold (Float scoreThreshold)
Sets the optional score threshold. Results with score below this value are rejected.
Overrides the score threshold specified in the TFLite Model Metadata, if any.
Parameters
| scoreThreshold |
|---|