在Android上使用TensorFlow的最简单方法是使用Android Studio。
参考官网:https://tensorflow.google.cn/mobile/android_build
使用Android Studio构建演示
先决条件:
先决条件:
1、按照其网站上的说明安装Android Studio。(确定SDK和NDK的版本符合Tensorflow的要求)
2、从Github克隆TensorFlow存储库:git clone https://github.com/tensorflow/tensorflow
打开Android Studio,然后选择打开一个现有的Android Studio项目。
点击运行按钮或使用 Run -> Run 'android' from the top menu。
在出现的“打开文件”或“项目”窗口中,选择tensorflow / examples / android目录,点击确定。
如果它要求您执行Gradle Sync,请单击确定。
你可能还需要安装各种平台和工具,如果遇到错误,如“Failed to find target with hash string 'android-23' ”,
打开build.gradle文件(可以在侧面板中找到1:Project并在Android下的Gradle Scripts zippy下找到它)。
查找nativeBuildSystem变量,如果它尚未设置为none,则将其设置为none:
// set to 'bazel', 'cmake', 'makefile', 'none'
def nativeBuildSystem = 'none'
点击运行按钮或使用 Run -> Run 'android' from the top menu。
如果它要求您使用即时运行,请单击继续不运行即时。
此外,您需要在此时启用开发人员选项并插入Android设备。运行结果如下,安装了4个app(红色圈出):

TF Classify:

TF Detect:

TF Stylize:

TF Speech:
