git clone https://github.com/tensorflow/tensorflow
https://github.com/tensorflow/tensorflow/tree/r2.1/tensorflow/lite/examples/android/app
咱们看到这个下面的例子程序已经移到专门的examples仓库里,而且用Android studio打开运行便可。java
TF Lite Android Example (Deprecated)python
This example has been moved to the new TensorFlow examples repo, and split into several distinct examples:android
首先安装JDK,从Oracle官网上下载并安装最新的JDK。c++
安装Homebrew:git
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" export PATH="/usr/local/bin:/usr/local/sbin:$PATH" brew install python@2 # or python (Python 3)
安装bazel:github
不一样版本的tenorflow 编译要求有不一样的bazel版本:ruby
cat .bazelversion
不一样版本的tensorflow对Android NDK和SDK版本也有要求。直接安装Android studio最简单。bash
选择Android API 在21版本以上。app
而后配置bazel:curl
./configure
进行android相关的配置就能够了。
能够按照下面的方式编译支持使用 TensorFlow select 运算符的 Android AAR:
bazel build --cxxopt='--std=c++11' -c opt \ --config=android_arm --config=monolithic \ //tensorflow/lite/java:tensorflow-lite-with-select-tf-ops
编译失败了,,,,后续看!!!