多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# iOS 应用中的 TF Mobile TensorFlow 通过以下步骤支持 iOS 应用: 1. 通过在项目的根目录中添加名为`Profile`的文件,在您的应用中包含 TF Mobile。将以下内容添加到`Profile`: ```py target 'Name-Of-Your-Project' pod 'TensorFlow-experimental' ``` 1. 运行`pod install`命令下载并安装 TensorFlow 实验舱。 2. 运行`myproject.xcworkspace`命令打开工作区,以便将预测代码添加到应用逻辑中。 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](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/ios) 在 iOS 项目中配置 TF 库后,可以通过以下四个步骤调用 TF 模型: 1. 加载模型: ```py PortableReadFileToProto(file_path, &tensorflow_graph); ``` 1. 创建会话: ```py tensorflow::Status s = session->Create(tensorflow_graph); ``` 1. 运行预测或推理并获得输出: ```py std::string input_layer = "input"; std::string output_layer = "output"; std::vector<tensorflow::Tensor> outputs; tensorflow::Status run_status = session->Run( {{input_layer, image_tensor}}, {output_layer}, {}, &outputs); ``` 1. 获取输出数据: ```py tensorflow::Tensor* output = &outputs[0]; ```