我一直在尝试使用为Inception模型设置的服务工具来设置重新训练的初始模型。我一直在关注教程here。我设法使用重新训练的模型设置服务器。我将以下代码添加到retrain.py文件的末尾以便将其导出。
export_path = "/tmp/export"
export_version = "1"
# Export inference model.
init_op = tf.group(tf.initialize_all_tables(), name='init_op')
saver = tf.train.Saver(sharded=True)
model_exporter = exporter.Exporter(saver)
signature = exporter.classification_signature(input_tensor=jpeg_data_tensor, scores_tensor=final_tensor)
model_exporter.init(sess.graph.as_graph_def(), default_graph_signature=signature)
model_exporter.export(FLAGS.export_dir, tf.constant(export_version), sess)
print('Successfully exported model to %s' % export_path)
暂时我只有4节课。我创建了模型,使用Tensorflow工具(没有Serving)我设法验证我的模型是否适用于测试图像。现在我正努力为它服务。我使用以下命令在模型上设置服务器:
bazel-bin/tensorflow_serving/example/inception_inference --port=9000 /tmp/export/ &> retrain.log &
我得到以下输出,并连续打印最后两行。
I tensorflow_serving/core/basic_manager.cc:189] Using InlineExecutor for BasicManager.
I tensorflow_serving/example/inception_inference.cc:383] Waiting for models to be loaded...
I tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:147] Aspiring version for servable default from path: /tmp/exportdir/00000001
I tensorflow_serving/session_bundle/session_bundle.cc:130] Attempting to load a SessionBundle from: /tmp/exportdir/00000001
I tensorflow_serving/session_bundle/session_bundle.cc:107] Running restore op for SessionBundle
I tensorflow_serving/session_bundle/session_bundle.cc:184] Done loading SessionBundle
I tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:147] Aspiring version for servable default from path: /tmp/exportdir/00000001
I tensorflow_serving/example/inception_inference.cc:349] Running...
I tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:147] Aspiring version for servable default from path: /tmp/exportdir/00000001
I tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:147] Aspiring version for servable default from path: /tmp/exportdir/00000001
当我尝试使用python客户端开始测试时,我得到以下错误,它似乎甚至没有找到我的输出:
vagrant@ubuntu:~/serving$ bazel-bin/tensorflow_serving/example/inception_client --image=/home/vagrant/AE.JPG
Traceback (most recent call last):
File "/home/vagrant/serving/bazel bin/tensorflow_serving/example/inception_client.runfiles/tf_serving/tensorflow_serving/example/inception_client.py", line 57, in <module>
tf.app.run()
File "/home/vagrant/serving/bazel-bin/tensorflow_serving/example/inception_client.runfiles/tf/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv))
File "/home/vagrant/serving/bazel-bin/tensorflow_serving/example/inception_client.runfiles/tf_serving/tensorflow_serving/example/inception_client.py", line 51, in main
result = stub.Classify(request, 5.0) # 10 secs timeout
File "/usr/local/lib/python2.7/dist-packages/grpc/framework/crust/implementations.py", line 75, in __call__
protocol_options, metadata, request)
File "/usr/local/lib/python2.7/dist-packages/grpc/framework/crust/_calls.py", line 109, in blocking_unary_unary
return next(rendezvous)
File "/usr/local/lib/python2.7/dist-packages/grpc/framework/crust/_control.py", line 415, in next
raise self._termination.abortion_error
grpc.framework.interfaces.face.face.NetworkError: NetworkError(code=StatusCode.INTERNAL, details="FetchOutputs node : not found")
有人可以指导我完成这件事吗?这是我第一次将Tensorflow用于实际项目。