xref: /aosp_15_r20/external/tflite-support/README.md (revision b16991f985baa50654c05c5adbb3c8bbcfb40082)
1*b16991f9SAndroid Build Coastguard Worker# TensorFlow Lite Support
2*b16991f9SAndroid Build Coastguard Worker
3*b16991f9SAndroid Build Coastguard WorkerTFLite Support is a toolkit that helps users to develop ML and deploy TFLite
4*b16991f9SAndroid Build Coastguard Workermodels onto mobile devices. It works cross-Platform and is supported on Java,
5*b16991f9SAndroid Build Coastguard WorkerC++ (WIP), and Swift (WIP). The TFLite Support project consists of the following
6*b16991f9SAndroid Build Coastguard Workermajor components:
7*b16991f9SAndroid Build Coastguard Worker
8*b16991f9SAndroid Build Coastguard Worker*   **TFLite Support Library**: a cross-platform library that helps to
9*b16991f9SAndroid Build Coastguard Worker    deploy TFLite models onto mobile devices.
10*b16991f9SAndroid Build Coastguard Worker*   **TFLite Model Metadata**: (metadata populator and metadata extractor
11*b16991f9SAndroid Build Coastguard Worker    library): includes both human and machine readable information about what a
12*b16991f9SAndroid Build Coastguard Worker    model does and how to use the model.
13*b16991f9SAndroid Build Coastguard Worker*   **TFLite Support Codegen Tool**: an executable that generates model wrapper
14*b16991f9SAndroid Build Coastguard Worker    automatically based on the Support Library and the metadata.
15*b16991f9SAndroid Build Coastguard Worker*   **TFLite Support Task Library**: a flexible and ready-to-use library for
16*b16991f9SAndroid Build Coastguard Worker    common machine learning model types, such as classification and detection,
17*b16991f9SAndroid Build Coastguard Worker    client can also build their own native/Android/iOS inference API on Task
18*b16991f9SAndroid Build Coastguard Worker    Library infra.
19*b16991f9SAndroid Build Coastguard Worker
20*b16991f9SAndroid Build Coastguard WorkerTFLite Support library serves different tiers of deployment requirements from
21*b16991f9SAndroid Build Coastguard Workereasy onboarding to fully customizable. There are three major use cases that
22*b16991f9SAndroid Build Coastguard WorkerTFLite Support targets at:
23*b16991f9SAndroid Build Coastguard Worker
24*b16991f9SAndroid Build Coastguard Worker*   **Provide ready-to-use APIs for users to interact with the model**. \
25*b16991f9SAndroid Build Coastguard Worker    This is achieved by the TFLite Support Codegen tool, where users can get the
26*b16991f9SAndroid Build Coastguard Worker    model interface (contains ready-to-use APIs) simply by passing the model to
27*b16991f9SAndroid Build Coastguard Worker    the codegen tool. The automatic codegen strategy is designed based on the
28*b16991f9SAndroid Build Coastguard Worker    TFLite metadata.
29*b16991f9SAndroid Build Coastguard Worker
30*b16991f9SAndroid Build Coastguard Worker*   **Provide optimized model interface for popular ML tasks**. \
31*b16991f9SAndroid Build Coastguard Worker    The model interfaces provided by the TFLite Support Task Library are
32*b16991f9SAndroid Build Coastguard Worker    specifically optimized compared to the codegen version in terms of both
33*b16991f9SAndroid Build Coastguard Worker    usability and performance. Users can also swap their own custom models with
34*b16991f9SAndroid Build Coastguard Worker    the default models in each task.
35*b16991f9SAndroid Build Coastguard Worker
36*b16991f9SAndroid Build Coastguard Worker*   **Provide the flexibility to customize model interface and build inference
37*b16991f9SAndroid Build Coastguard Worker    pipelines**. \
38*b16991f9SAndroid Build Coastguard Worker    The TFLite Support Util Library contains varieties of util methods and data
39*b16991f9SAndroid Build Coastguard Worker    structures to perform pre/post processing and data conversion. It is also
40*b16991f9SAndroid Build Coastguard Worker    designed to match the behavior of TensorFlow modules, such as TF.Image and
41*b16991f9SAndroid Build Coastguard Worker    TF.text, ensuring consistency from training to inferencing.
42*b16991f9SAndroid Build Coastguard Worker
43*b16991f9SAndroid Build Coastguard WorkerSee the
44*b16991f9SAndroid Build Coastguard Worker[documentation on tensorflow.org](https://www.tensorflow.org/lite/inference_with_metadata/overview)
45*b16991f9SAndroid Build Coastguard Workerfor more instruction and examples.
46*b16991f9SAndroid Build Coastguard Worker
47*b16991f9SAndroid Build Coastguard Worker## Build Instructions
48*b16991f9SAndroid Build Coastguard Worker
49*b16991f9SAndroid Build Coastguard WorkerWe use Bazel to build the project. When you're building the Java (Android)
50*b16991f9SAndroid Build Coastguard WorkerUtils, you need to set up following env variables correctly:
51*b16991f9SAndroid Build Coastguard Worker
52*b16991f9SAndroid Build Coastguard Worker*   `ANDROID_NDK_HOME`
53*b16991f9SAndroid Build Coastguard Worker*   `ANDROID_SDK_HOME`
54*b16991f9SAndroid Build Coastguard Worker*   `ANDROID_NDK_API_LEVEL`
55*b16991f9SAndroid Build Coastguard Worker*   `ANDROID_SDK_API_LEVEL`
56*b16991f9SAndroid Build Coastguard Worker*   `ANDROID_BUILD_TOOLS_VERSION`
57*b16991f9SAndroid Build Coastguard Worker
58*b16991f9SAndroid Build Coastguard Worker## Contact us
59*b16991f9SAndroid Build Coastguard Worker
60*b16991f9SAndroid Build Coastguard WorkerLet us know what you think about TFLite Support by creating a
61*b16991f9SAndroid Build Coastguard Worker[new Github issue](https://github.com/tensorflow/tflite-support/issues/new), or
62*b16991f9SAndroid Build Coastguard Workeremail us at [email protected].
63