STT-tensorflow/tensorflow/lite/java/demo
TensorFlower Gardener e7d27d8507 Merge pull request from freedomtan:gpu_delegate_already_allows_quant
PiperOrigin-RevId: 327630219
Change-Id: I04153386bcf1a80af7356446ee279d29fb04d342
2020-08-20 08:31:04 -07:00
..
app Merge pull request from freedomtan:gpu_delegate_already_allows_quant 2020-08-20 08:31:04 -07:00
gradle/wrapper
.gitignore
build.gradle
gradle.properties
gradlew
gradlew.bat
README.md Update build commands 2020-02-14 16:14:14 -08:00
settings.gradle

TF Lite Android Image Classifier App Example

A simple Android example that demonstrates image classification using the camera.

Building in Android Studio with TensorFlow Lite AAR from JCenter.

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.

Building from Source with Bazel

  1. Follow the Bazel steps for the TF Demo App:

  2. Install Bazel and Android Prerequisites. It's easiest with Android Studio.

    • You'll need at least SDK version 23.
    • Make sure to install the latest version of Bazel. Some distributions ship with Bazel 0.5.4, which is too old.
    • Bazel requires Android Build Tools 28.0.0 or higher.
    • You also need to install the Android Support Repository, available through Android Studio under Android SDK Manager -> SDK Tools -> Android Support Repository.
  3. 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.

    • Make sure the api_level in WORKSPACE is set to an SDK version that you have installed.
    • By default, Android Studio will install the SDK to ~/Android/Sdk and the NDK to ~/Android/Sdk/ndk-bundle.
  4. Build the app with Bazel. The demo needs C++11:

bazel build -c opt //tensorflow/lite/java/demo/app/src/main:TfLiteCameraDemo
  1. Install the demo on a debug-enabled device:
adb install bazel-bin/tensorflow/lite/java/demo/app/src/main/TfLiteCameraDemo.apk