如何构建和运行TensorFlow Lite iOS示例?
(https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/examples)
答案 0 :(得分:2)
以下是从源代码(方法1)和Pod文件(方法2)构建和运行以下TensorFlow Lite iOS示例的说明;
(例如相机分类模型; mobilenet_quant_v1_224.tflite
/ labels.txt
,简单分类模型; mobilenet_v1_1.0_224.tflite
/ labels.txt
)
基于的指令; https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/lite/g3doc/ios.md
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
git checkout r1.10
(选择包含tensorflow / contrib / lite / download_dependencies.sh的tensorflow版本)
cd tensorflow/contrib/lite
./download_dependencies.sh
./build_ios_universal_lib.sh
cd examples/ios
./download_models.sh
(将张量流模型下载到simple/data
和camera/data
)tensorflow/contrib/lite/examples/ios/simple/simple.xcodeproj
/ camera/tflite_camera_example.xcworkspace
):
tensorflow/contrib/lite/gen/lib/libtensorflow-lite.a
[INSERTTENSORFLOWSOURCELOCATIONHERE]/tensorflow/contrib/lite/gen/lib
[INSERTTENSORFLOWSOURCELOCATIONHERE]
(tensorflow git存储库的根文件夹)[INSERTTENSORFLOWSOURCELOCATIONHERE]/tensorflow/contrib/lite/downloads
[INSERTTENSORFLOWSOURCELOCATIONHERE]/tensorflow/contrib/lite/downloads/flatbuffers/include
data
的新组data
文件夹项目从tensorflow/contrib/lite/example/ios/simple/data
(grace_hopper.jpg
,labels.txt
,mobilenet...
)拖放到xCode中新创建的数据文件夹中(在询问时,选择目标:如果需要,复制项目)AppDelegate.m
/ tensorflow/contrib/lite/examples/ios/simple/AppDelegate.mm
的内容相应地修改应用程序现有的.h
tensorflow/contrib/lite/example/ios/simple
(ios_image_load.h
,ios_image_load.mm
,RunModelViewController.h
,RunModelViewController.mm
,RunModelViewController.xib
拖放源代码项[不:{{ 1}},AppDelegate.h
,AppDelegate.mm
])基于的指令; https://www.tensorflow.org/mobile/tflite/demo_ios
main.mm
git clone https://github.com/tensorflow/tensorflow
cd tensorflow
/ git checkout r1.10
5b63ee85acc0676a35252c50014a178b55aabaa4
cd tensorflow/contrib/lite/examples/ios
(将张量流模型下载到./download_models.sh
和simple/data
)camera/data
/ cd camera
cd simple
pod repo update
pod install
/ open tflite_camera_example.xcworkspace
open simple.xcodeproj
/ tflite_camera_example
项目(蓝色文档图标)-[默认目标]-常规simple
项目必需)