我想使用TensorFlow Serving为自定义模型提供服务(没有预训练的起点)。
我已经通过Docker完成了TensorFlow Serving教程中Inception的预-Kubernetes部分:http://tensorflow.github.io/serving/serving_inception 我大致理解Bazel编译是所有工作的核心。但是我试图理解来自tensorflow_serving.apis的生成的predict_pb2是如何工作的,以便我可以换入自己的自定义模型。
明确一下,这是inception_client.py中的main目前的样子:
我已经通过Docker完成了TensorFlow Serving教程中Inception的预-Kubernetes部分:http://tensorflow.github.io/serving/serving_inception 我大致理解Bazel编译是所有工作的核心。但是我试图理解来自tensorflow_serving.apis的生成的predict_pb2是如何工作的,以便我可以换入自己的自定义模型。
明确一下,这是inception_client.py中的main目前的样子:
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)
这段代码中的predict_pb2.PredictRequest()
是由Bazel生成的,对我来说很难解包并进行调试。但是我想将其重新指向一个完全不同的已保存模型,该模型有自己的.pb文件等。
我应该如何引用一个不同的已保存模型呢?
model_spec.name
的问题。您能否再解释一下? - BeeNoisy