TensorFlow (二) - TensorFlow iOS Examples

TensorFlow (二) - TensorFlow iOS Examples

Build

编译可参考 TF 的 ios_examples 的 ReadMe

  • 升级 Xcode 到 7.3 版本及更高
  • 安装命令行工具。
1
$ xcode-select --install
  • 安装 Homebrew, automake, libtool
1
2
3
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install automake
$ brew install libtool
  • 执行 tensorflow/contrib/makefile 路径下的 build_all_ios.sh 脚本,编译大概一个半小时。
1
2
$ cd tensorflow/contrib/makefile
$ ./build_all_ios.sh

执行成功后在 makefile/gen/lib 下生成 libtensorflow-core.a 库。

Run Examples

此时还差一步即可运行 TF 提供的Demo:添加数据模型。

执行下面命令,或者可以手动下载 Inception。然后copy到相应路径下。

1
2
3
4
5
6
7
$ mkdir -p ~/graphs
$ curl -o ~/graphs/inception5h.zip \
https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip \
&& unzip ~/graphs/inception5h.zip -d ~/graphs/inception5h
$ cp ~/graphs/inception5h/* tensorflow/contrib/ios_examples/benchmark/data/
$ cp ~/graphs/inception5h/* tensorflow/contrib/ios_examples/camera/data/
$ cp ~/graphs/inception5h/* tensorflow/contrib/ios_examples/simple/data/

现在可以运行三个实例工程啦~