如何将tensorflow程序移植到手机APP

首先,我们先介绍tensorflow上提供的demo。
我们这里用Bazel。

一.下载tensorflow。

git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git

二.安装Bazel。安装教程:

https://docs.bazel.build/versions/master/install.html

三.安装NDK。只需下载解压即可。注意,这里最好下载12版本的。其他版本亲测,会出错。

https://developer.android.com/ndk/downloads/older_releases.html#ndk-12b-downloads

四.安装SDK。SDK可以单独安装,但是我们这里直接安装Android stdio ,然后会提示我们安装SDK。下载方法:

https://developer.android.com/studio/index.html

五.修改workspace文件

# Uncomment and update the paths in these entries to build the Android demo.
android_sdk_repository(
    name = "androidsdk",
    api_level = 26,
    # Ensure that you have the build_tools_version below installed in the
    # SDK manager as it updates periodically.
    build_tools_version = "26.0.1",
    # Replace with path to Android SDK on your system
    path = "/home/no1/Android/Sdk/",
)
#
# Android NDK r12b is recommended (higher may cause issues with Bazel)
android_ndk_repository(
    name="androidndk",
    path="/home/no1/android-ndk-r12b/",
    # This needs to be 14 or higher to compile TensorFlow.
    # Please specify API level to >= 21 to build for 64-bit
    # archtectures or the Android NDK will automatically select biggest
    # API level that it supports without notice.
    # Note that the NDK version is not the API level.
    api_level=26)

六.编译:

bazel build -c opt //tensorflow/examples/android:tensorflow_demo

如果出错则换用这个指令:

bazel build --noincremental_dexing //tensorflow/examples/android:tensorflow_demo

完成之后:出现如下情况表示编译完成:
编译成功结果

然后在目录:tensorflow/bazel-bin/tensorflow/examples/android 下找到我们想要的apk,传到手机上,安装之后,可以看到有四个小功能的APP

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值