TfLite
Stay organized with collections
Save and categorize content based on your preferences.
Entry point for the TensorFlow Lite (TFLite) Java API provided by Google Play
services.
Once the initialization has finished successfully, you can use the regular Tensorflow Lite APIs
. To benefit from
the Google Play services runtime, remember to initialize your InterpreterApi
instance with options.setRuntime(FROM_SYSTEM)
or options.setRuntime(PREFER_SYSTEM_OVER_APPLICATION)
.
For more information about this API, see the TensorFlow Lite guide
.
Public Method Summary
static TfLiteClient |
|
static Task<Status> |
|
static Task< Void
> |
initialize
( Context
context) Initializes the TFLite API with the default options (which are to disable
loading the GPU delegate).
|
static Task< Void
> |
initialize
( Context
context, TfLiteInitializationOptions options) Initializes the TFLite API with the specified options.
|
Inherited Method Summary
From class java.lang.Object
Public Methods
public static TfLiteClient
getClient
( Context
context)
public static Task<Status>
getTfliteModuleAvailabilityStatus
( Context
context)
Gets the availability status of the TFLite dynamite module.
public static Task< Void
>
initialize
( Context
context)
Initializes the TFLite API with the default options (which are to disable loading
the GPU delegate). TFLite API methods should only be called after the task returned by
this method has successfully completed.
This method returns a Task<Void>
, so you should wait for the task
to be completed, but the return value of the Task is irrelevant.
public static Task< Void
>
initialize
( Context
context,
TfLiteInitializationOptions options)
Initializes the TFLite API with the specified options. TFLite API methods should
only be called after the task returned by this method has successfully completed.
This method returns a Task<Void>
. Make sure to call TFLite API
methods only after the Task
has successfully completed. The return value
of the Task
, though, is irrelevant (will always be null
).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-11-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-11-18 UTC."],[[["\u003cp\u003e\u003ccode\u003eTfLite\u003c/code\u003e is the entry point for the TensorFlow Lite Java API provided by Google Play services.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003eTfLite.initialize()\u003c/code\u003e to initialize the TFLite API before using Tensorflow Lite APIs.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the initialization with \u003ccode\u003eTfLiteInitializationOptions\u003c/code\u003e to control runtime delegation (e.g., GPU).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eTfLite.getClient()\u003c/code\u003e provides a \u003ccode\u003eTfLiteClient\u003c/code\u003e instance for interaction with the \u003ccode\u003eOptionalModuleApi\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# TfLite\n\npublic class **TfLite** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nEntry point for the TensorFlow Lite (TFLite) Java API provided by Google Play\nservices.\n\nOnce the initialization has finished successfully, you can use [the regular Tensorflow Lite APIs](/android/reference/com/google/android/gms/tflite/java/www.tensorflow.org/lite/guide/android). To benefit from\nthe Google Play services runtime, remember to initialize your `InterpreterApi`\ninstance with `options.setRuntime(FROM_SYSTEM)` or\n`options.setRuntime(PREFER_SYSTEM_OVER_APPLICATION)`.\n\nFor more information about this API, see the [TensorFlow Lite guide](/android/reference/com/google/android/gms/tflite/java/www.tensorflow.org/lite/android/play_services). \n\n### Public Method Summary\n\n|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static TfLiteClient | [getClient](/android/reference/com/google/android/gms/tflite/java/TfLite#getClient(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Returns a [TfLiteClient](/android/reference/com/google/android/gms/tflite/client/TfLiteClient) instance that can eventually be used as an argument for [OptionalModuleApi](/android/reference/com/google/android/gms/common/api/OptionalModuleApi). |\n| static Task\\\u003cStatus\\\u003e | [getTfliteModuleAvailabilityStatus](/android/reference/com/google/android/gms/tflite/java/TfLite#getTfliteModuleAvailabilityStatus(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Gets the availability status of the TFLite dynamite module. |\n| static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [initialize](/android/reference/com/google/android/gms/tflite/java/TfLite#initialize(android.content.Context))([Context](//developer.android.com/reference/android/content/Context.html) context) Initializes the TFLite API with the default options (which are to disable loading the GPU delegate). |\n| static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e | [initialize](/android/reference/com/google/android/gms/tflite/java/TfLite#initialize(android.content.Context,%20com.google.android.gms.tflite.client.TfLiteInitializationOptions))([Context](//developer.android.com/reference/android/content/Context.html) context, TfLiteInitializationOptions options) Initializes the TFLite API with the specified options. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public static TfLiteClient\n**getClient** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nReturns a [TfLiteClient](/android/reference/com/google/android/gms/tflite/client/TfLiteClient)\ninstance that can eventually be used as an argument for [OptionalModuleApi](/android/reference/com/google/android/gms/common/api/OptionalModuleApi). \n\n#### public static Task\\\u003cStatus\\\u003e\n**getTfliteModuleAvailabilityStatus** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nGets the availability status of the TFLite dynamite module. \n\n#### public static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **initialize** ([Context](//developer.android.com/reference/android/content/Context.html) context)\n\nInitializes the TFLite API with the default options (which are to disable loading\nthe GPU delegate). TFLite API methods should only be called after the task returned by\nthis method has successfully completed.\n\nThis method returns a `Task\u003cVoid\u003e`, so you should wait for the task\nto be completed, but the return value of the Task is irrelevant. \n\n#### public static Task\\\u003c[Void](//developer.android.com/reference/java/lang/Void.html)\\\u003e **initialize** ([Context](//developer.android.com/reference/android/content/Context.html) context, TfLiteInitializationOptions options)\n\nInitializes the TFLite API with the specified options. TFLite API methods should\nonly be called after the task returned by this method has successfully completed.\n\nThis method returns a `Task\u003cVoid\u003e`. Make sure to call TFLite API\nmethods only after the `Task` has successfully completed. The return value\nof the `Task`, though, is irrelevant (will always be `null`)."]]