iOS 集成tensorflow
来源:互联网 发布:燕郊seo 编辑:程序博客网 时间:2024/05/29 15:21
集成 tensorflow
tensorflow 是Google开放的关于机器学习的框架,最近正式版本1.0发布了,作者就自己玩了一下,关于踩坑有以下:
当在Github上下载了整个包,我们需要在终端进入tensorflow/tensorflow/contrib/makefile,可以看到有一个shell脚本:build_all_ios.sh
坑1:
执行build_all_ios.sh 脚本时候的网络环境,sed: tensorflow/contrib/makefile/downloads/eigen/Eigen/src/Core/arch/NEON/Complex.h: No such file or directory
解决办法是:
需要当前网络环境支持https
上一步完成之后,执行脚本之后,会遇到
坑2:
+ autoreconf -f -i -Wall,no-obsolete
./autogen.sh: line 48: autoreconf: command not found
解决办法:
brew install autoconf
上一步完成之后,继续执行脚本,遇到
坑3:
+ autoreconf -f -i -Wall,no-obsolete
Can't exec "aclocal": No such file or directory at /usr/local/Cellar/autoconf/2.69/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory
解决办法:
brew install automake
上一步完成之后,继续执行脚本,遇到
坑4:
+ autoreconf -f -i -Wall,no-obsolete
configure.ac:30: error: possibly undefined macro: AC_PROG_LIBTOOL
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/local/Cellar/autoconf/2.69/bin/autoconf failed with exit status: 1
解决办法是:
brew install libtool
继续执行脚本,没有问题了,整个脚本执行需要时间,最后完成的标志是:
tensorflow/tensorflow/contrib/makefile/gen/protobuf_ios/lib路径下有libprotobuf.a,libprotobuf-lite.a
tensorflow/tensorflow/contrib/makefile/gen/lib路径下有libtensorflow-core.a
搞定以上之后,进入路径:
tensorflow/contrib/ios_examples/simple
打开其中的tf_ios_makefile_example.xcodeproj工程,编译通过,点击App中的Run Model按钮,执行完成,你会看到tensorflow_inception_graph.pb文件被加载完成
然后进入路径:tensorflow/contrib/ios_examples/camera
打开其中的camera_example.xcodeproj工程,在带有摄像头的真机上编译执行,然后就大功告成,可以自己玩了
Creating your Own App
You'll need to update various settings in your app to link against TensorFlow. You can view them in the example projects, but here's a full rundown:
The
compile_ios_tensorflow.sh
script builds a universal static library intensorflow/contrib/makefile/gen/lib/libtensorflow-core.a
. You'll need to add this to your linking build stage, and in Search Paths addtensorflow/contrib/makefile/gen/lib
to the Library Search Paths setting.You'll also need to add
libprotobuf.a
andlibprotobuf-lite.a
fromtensorflow/contrib/makefile/gen/protobuf_ios/lib
to your Build Stages and Library Search Paths.The Header Search paths needs to contain:
- the root folder of tensorflow,
tensorflow/contrib/makefile/downloads/protobuf/src
tensorflow/contrib/makefile/downloads
,tensorflow/contrib/makefile/downloads/eigen
, andtensorflow/contrib/makefile/gen/proto
.
In the Linking section, you need to add
-force_load
followed by the path to the TensorFlow static library in the Other Linker Flags section. This ensures that the global C++ objects that are used to register important classes inside the library are not stripped out. To the linker, they can appear unused because no other code references the variables, but in fact their constructors have the important side effect of registering the class.You'll need to include the Accelerate framework in the "Link Binary with Libraries" build phase of your project.
C++11 support (or later) should be enabled by setting
C++ Language Dialect
toGNU++11
(orGNU++14
), andC++ Standard Library
tolibc++
.The library doesn't currently support bitcode, so you'll need to disable that in your project settings.
Remove any use of the
-all_load
flag in your project. The protocol buffers libraries (full and lite versions) contain duplicate symbols, and the-all_load
flag will cause these duplicates to become link errors. If you were using-all_load
to avoid issues with Objective-C categories in static libraries, you may be able to replace it with the-ObjC
flag.
- iOS 集成tensorflow
- iOS集成TensorFlow Lite配置教程
- Kaldi 现在提供 TensorFlow 集成
- android studio 集成TensorFlow Demo
- Kaldi现在提供TensorFlow集成
- tensorflow 安装 和集成到IDEA
- 机器学习:如何在安卓上集成TensorFlow
- iOS:集成iAd广告
- iOS集成常见问题
- IOS 集成 phonegap
- ios shareSDK集成
- IOS XMPPFramwork集成
- IOS集成Alipay教程
- iOS集成支付宝
- iOS极光推送集成
- iOS的持续集成
- iOS集成支付宝
- iOS集成支付宝
- Asp.Net MVC4.0 官方教程 入门指南之六--查看Edit方法和Edit视图
- apk优化-apk瘦身
- unity ios打包真机调试 Shader.Find()找不到问题
- subline快捷键的使用
- 透彻理解 Java synchronized 对象锁和类锁的区别
- iOS 集成tensorflow
- 聊聊并发(八)——Fork/Join框架介绍
- 备忘录模式
- linux 下tomcat6 配置为服务
- java中的抽象类和接口区别
- LeetCode 22. Generate Parentheses
- SVN uuid 报错解决方法
- linux centos6.5下安装svn方法
- Asp.Net MVC4.0 官方教程 入门指南之七--增加搜索方法和视图