TensorFlow 学习之旅(三)

TensorFlow在图像识别中的应用
参考资料:http://www.csdn.net/article/2015-12-16/2826496?_t=t

C++ API的使用方法
用C++运行同样的Inception-v3模型
一、下载定义模型的GraphDef文件(在TensorFlow的根目录下运行):

wget https://storage.googleapis.com/download.tensorflow.org/models/inception_dec_2015.zip -O tensorflow/examples/label_image/data/inception_dec_2015.zip
TensorFlow 学习之旅(三)_第1张图片

learning@learning-virtual-machine:~/tensorflow$ wget https://storage.googleapis.com/download.tensorflow.org/models/inception_dec_2015.zip -O tensorflow/examples/label_image/data/inception_dec_2015.zip
--2016-05-10 11:13:05--  https://storage.googleapis.com/download.tensorflow.org/models/inception_dec_2015.zip
Resolving storage.googleapis.com (storage.googleapis.com)... 216.58.199.16, 2404:6800:4005:803::2010
Connecting to storage.googleapis.com (storage.googleapis.com)|216.58.199.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 88631107 (85M) [application/zip]
Saving to: ‘tensorflow/examples/label_image/data/inception_dec_2015.zip’

tensorflow/examp 100%[===========>]  84.52M  4.50MB/s   in 18s    

2016-05-10 11:13:24 (4.70 MB/s) - ‘tensorflow/examples/label_image/data/inception_dec_2015.zip’ saved [88631107/88631107]

unzip tensorflow/examples/label_image/data/inception_dec_2015.zip -d tensorflow/examples/label_image/data/

TensorFlow 学习之旅(三)_第2张图片

二、编译加载和运行模型的C++代码。
下载并安装TensorFlow,在shell终端执行命令编译例子:

bazel build tensorflow/examples/label_image/…

这里写图片描述

三、生成二进制可执行程序,然后运行:

bazel-bin/tensorflow/examples/label_image/label_image

出现问题,待解决

ERROR: /home/learning/tensorflow/tensorflow/cc/BUILD:28:1: Linking of rule '//tensorflow/cc:ops/candidate_sampling_ops_gen_cc' failed: gcc failed: error executing command /usr/bin/gcc -o bazel-out/host/bin/tensorflow/cc/ops/candidate_sampling_ops_gen_cc -pthread -no-canonical-prefixes -B/usr/bin -B/usr/bin -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' ... (remaining 3 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
gcc.real: fatal error: -fuse-linker-plugin, but liblto_plugin.so not found
compilation terminated.
INFO: Elapsed time: 5572.445s, Critical Path: 5407.48s
learning@learning-virtual-machine:~/tensorflow$ 

TensorFlow 学习之旅(三)_第3张图片

你可能感兴趣的:(tensorflow)