我想将TensorFlow服务用于自定义模型(没有预先训练的起点).
我使用Docker通过TensorFlow服务教程的前Kubernetes部分,使用Docker:http://tensorflow.github.io/serving/serving_inception
我(大致)理解Bazel编译是一切工作的核心.但我试图了解生成predict_pb2的tensorflow_serving.apis工作方式,以便我可以交换自己的自定义模型.
需要明确的是,这是什么main在inception_client.py目前的样子:
def main(_):
host, port = FLAGS.server.split(':')
channel = implementations.insecure_channel(host, int(port))
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)
# Send request
with open(FLAGS.image, 'rb') as f:
# See prediction_service.proto for gRPC request/response details.
data = f.read()
request = predict_pb2.PredictRequest()
request.model_spec.name = 'inception'
request.model_spec.signature_name = 'predict_images'
request.inputs['images'].CopyFrom(
tf.contrib.util.make_tensor_proto(data, shape=[1]))
result = stub.Predict(request, 10.0) # 10 secs timeout
print(result)
Run Code Online (Sandbox Code Playgroud)
predict_pb2.PredictRequest()由于它是Bazel生成的,我很难解压缩和调试正在做的事情.但是我想重新指出一个完全不同的,已保存的模型,它有自己的.pb文件等.
我如何参考其他保存的模型?