Tensorflow 静态库制作(ios)

1.环境检查

是否安装xcode

是否安装homebrew

是否通过homebrew 安装 automake

是否通过homebrew安装libtool

是否下载TensorFlow源码(github: https://github.com/tensorflow/tensorflow)

2.开始制作静态库

找到 build_all_ios.sh 并执行

打开终端,输入命令进入到 build_all_ios.sh 所在的文件夹并执行这个shell脚本文件

AppledeMacBook-Pro:~ apple$ cd /Users/apple/Downloads/tensorflow-1.1.0/tensorflow/contrib/makefile      

AppledeMacBook-Pro:makefile apple$ ./build_all_ios.sh

执行过程中如果出现报错,例如

./autogen.sh: line 48: autoreconf: command not found  (,原因linux系统缺少autoreconf工具)
》》》》》》》》》》需要安装3 automake

AppledeMacBook-Pro:~ apple$ brew install automake


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.
》》》》》》》》》》需要安装  libtool

AppledeMacBook-Pro:~ apple$ brew install libtool
 

然后重新执行 build_all_ios.sh 

3.开始等待,编译时间真的很长,大概花费了75分钟的时间

为啥时间这么长 ?而且 libtensorflow-core.a 近500M ? 仔细看一下其他相关文件不难发现。

首先 build_all_ios.sh  是不是意味着编译所有指令集的静态库 ?

打开 compile_ios_protobuf.sh 即可发现使用xcrun命令

make distclean
./configure
--host=i386-apple-${OSX_VERSION}

--host=x86_64-apple-${OSX_VERSION}

--host=armv7-apple-${OSX_VERSION}

--host=armv7s-apple-${OSX_VERSION}

--host=armv64-apple-${OSX_VERSION}

然后compile_ios_tensorflow.sh 合成全指令集的静态库  libtensorflow-core.a 

4.静态库制作完成,使用TensorFlow自带的sample工程看看玩一玩

5.工程打开了但是无法运行,因为缺少 模型文件

下载一个测试的用一下:https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip

解压后 得到

imagenet_comp_graph_label_strings.txt

tensorflow_inception_graph.pb

把这两个文件copy到 camera 工程中的data文件夹中,至此,一切准备就绪

6.再次跑一下工程可以看到效果,附上一些测试截图

7.彩蛋---竟然有一个成熟的女子朗读出来程序推算出来的内容 Computer keyboard

致谢:

https://www.jianshu.com/p/764357ea773a

https://blog.csdn.net/qwer8442949/article/details/72518936

原文地址:https://www.cnblogs.com/madaha/p/10054527.html