TF Mobile in iOS apps
TensorFlow enables support for iOS apps by following these steps:
- Include TF Mobile in your app by adding a file named
Profile
in the root directory of your project. Add the following content to theProfile
:
target 'Name-Of-Your-Project' pod 'TensorFlow-experimental'
- Run the
pod install
command to download and install the TensorFlow Experimental pod. - Run the
myproject.xcworkspace
command to open the workspace so you can add the prediction code to your application logic.
Note
To create your own TensorFlow binaries for iOS projects, follow the instructions at this link: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/ios
Once the TF library is configured in your iOS project, you can call the TF model with the following four steps:
- Load the model:
PortableReadFileToProto(file_path, &tensorflow_graph);
- Create a session:
tensorflow::Status s = session->Create(tensorflow_graph);
- Run the prediction or inference and get the outputs:
std::string input_layer...