A simple Android example that demonstrates image classification using the camera.
The build.gradle is configured to use TensorFlow Lite's nightly build.
If you see a build error related to compatibility with Tensorflow Lite‘s Java API (example: method X is undefined for type Interpreter), there has likely been a backwards compatible change to the API. You will need to pull new app code that’s compatible with the nightly build and may need to first wait a few days for our external and internal code to merge.
Follow the Bazel steps for the TF Demo App:
Install Bazel and Android Prerequisites. It's easiest with Android Studio.
28.0.0
or higher.Android SDK Manager -> SDK Tools -> Android Support Repository
.Edit your WORKSPACE
to add SDK and NDK targets.
NOTE: As long as you have the SDK and NDK installed, the ./configure
script will create these rules for you. Answer “Yes” when the script asks to automatically configure the ./WORKSPACE
.
api_level
in WORKSPACE
is set to an SDK version that you have installed.~/Android/Sdk
and the NDK to ~/Android/Sdk/ndk-bundle
.Build the app with Bazel. The demo needs C++11:
bazel build -c opt //tensorflow/lite/java/demo/app/src/main:TfLiteCameraDemo
adb install bazel-bin/tensorflow/lite/java/demo/app/src/main/TfLiteCameraDemo.apk