We will proceed with the recipe as follows:
- Install cocoapods with the following commands
sudo gem install cocoapods
pod setup
Setting up CocoaPods master repo
$ /usr/local/git/current/bin/git clone https://github.com/CocoaPods/Specs.git master --progress
Cloning into 'master'...
remote: Counting objects: 1602077, done.
remote: Compressing objects: 100% (243/243), done.
remote: Total 1602077 (delta 125), reused 172 (delta 74), pack-reused 1601747
Receiving objects: 100% (1602077/1602077), 432.12 MiB | 1.83 MiB/s, done.
Resolving deltas: 100% (849517/849517), done.
Checking out files: 100% (188907/188907), done.
- Install TensorFlow distribution with CocoaPods:
cd TensorFlow/TensorFlow/examples/ios/benchmark
pod install
Analyzing dependencies
Downloading dependencies
Installing TensorFlow-experimental (1.1.1)
Generating Pods project
Integrating client project
[!] Please close any current Xcode sessions and use `tf_benchmark_example.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
- Download some sample data from Inception v1. Extract the label and graph files into the data folders inside both the simple and camera folders:
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/examples/ios/benchmark/data/
cp ~/graphs/inception5h/* TensorFlow/examples/ios/camera/data/
cp ~/graphs/inception5h/* TensorFlow/examples/ios/simple/data/
- Download an image used as a test from and copy it into the benchmark directory:
https://upload.wikimedia.org/wikipedia/commons/5/55/Grace_Hopper.jpg
cp grace_hopper.jpg ../../benchmark/data/
An image of Grace Hopper
- Open the sample project used previously. The following command will open Xcode with TensorFlow already available: After that, run compile, as shown in the following code and image:
open tf_benchmark_example.xcworkspace
- Look at the results in the iPhone simulator. The image used in step 4 is recognized as being an image of a military uniform, according to the Inception v1 categories:
An example of Iphone application for Tensorflow computation