TensorFlow学习笔记(五): Tensorflow on Android

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/nxcxl88/article/details/53380627

1. 参考

一篇中文的安装步骤:http://blog.csdn.net/wei220000/article/details/50985609

原文可参考: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/android


2. 推荐版本组合

bazel 最新版本

SDK build tools 最新版本

NDK: r11c (dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip)


3. 注意问题

3.1. bazel版本和ndk版本问题

在2016年11月,bazel的版本升级到了0.4.0,但是依然会出现ndk版本的错误:“Could not read RELEASE.TXT in Android NDK”

按照tensorflow的帖子(https://github.com/tensorflow/tensorflow/issues/3175),可以看到解决方法就是限制ndk的版本到r11c以下。

ndk r11c的下载地址:dl.google.com/android/repository/android-ndk-r11c-linux-x86_64.zip


3.2. WORKSPACE文件配置

关于API level 和SDK版本对应的问题,可以从这个网站查找:https://developer.android.com/guide/topics/manifest/uses-sdk-element.html,也可以查看Android Stuido中SDK Manager的列表。

如果API level 和 build tools的版本设置错误,常见的错误就是出现某个工具找不到,如

“@androidsdk//:zipalign_binary: missing input file '@androidsdk//:build-tools/25.2.3/zipalign”

另外,api_level必须设置为比23大的数,否则可能出现以下一类的错误(https://github.com/tensorflow/tensorflow/issues/3847)

error: cannot find symbol
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                                                    ^
  symbol:   variable M
  location: class VERSION_CODES

3.3.一些依赖包

如果直接用git clone指令下载tensorflow,就可能漏下一些依赖包,这样在bazel编译的过程中就需要联网下载依赖包。可以在git clone的时候加入“--recurse_submodules”选项即可。


4. 运行结果

运行的而结果是视频图像以及预测的结果和概率。


猜你喜欢

转载自blog.csdn.net/nxcxl88/article/details/53380627