TF Mobile in Android apps
The TensorFlow ecosystem enables it to be used in Android apps through the interface class TensorFlowInferenceInterface
, and the TensorFlow Java API in the jar file libandroid_tensorflow_inference_java.jar
. You can either use the jar file from the JCenter, download a precompiled jar from ci.tensorflow.org
, or build it yourself.
The inference interface has been made available as a JCenter package and can be included in the Android project by adding the following code to the build.gradle
file:
allprojects { repositories { jcenter() } } dependencies { compile 'org.tensorflow:tensorflow-android:+' }
Note
Instead of using the pre-built binaries from the JCenter, you can also build them yourself using Bazel or Cmake by following the instructions at this link: https://github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/contrib/android/README.md.
Once the TF library is configured in your Android project, you can call the TF model with the following four steps...