Skip to content

Instantly share code, notes, and snippets.

@iandow
Created August 27, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandow/0a39fe58784fdbb5d276d03b19ec4f02 to your computer and use it in GitHub Desktop.
Save iandow/0a39fe58784fdbb5d276d03b19ec4f02 to your computer and use it in GitHub Desktop.
def main(_):
channel = grpc.insecure_channel(FLAGS.server)
stub = prediction_service_pb2_grpc.PredictionServiceStub(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 = 'model'
# request.model_spec.signature_name = 'predict_images'
request.model_spec.signature_name = tf.saved_model.signature_constants.DEFAULT_SERVING_SIGNATURE_DEF_KEY
request.inputs['image'].CopyFrom(
tf.contrib.util.make_tensor_proto(data, shape=[1]))
result = stub.Predict(request, 10.0) # 10 secs timeout
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment