Skip to content

Instantly share code, notes, and snippets.

@gauravkaila
Last active January 25, 2019 11:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gauravkaila/ec6b12592e6c2103e8622292e83aecdd to your computer and use it in GitHub Desktop.
Save gauravkaila/ec6b12592e6c2103e8622292e83aecdd to your computer and use it in GitHub Desktop.
# Create stub
host, port = FLAGS.server.split(':')
channel = implementations.insecure_channel(host, int(port))
stub = prediction_service_pb2.beta_create_PredictionService_stub(channel)
# Create prediction request object
request = predict_pb2.PredictRequest()
# Specify model name (must be the same as when the TensorFlow serving serving was started)
request.model_spec.name = 'obj_det'
# Initalize prediction
# Specify signature name (should be the same as specified when exporting model)
request.model_spec.signature_name = "detection_signature"
request.inputs['inputs'].CopyFrom(
tf.contrib.util.make_tensor_proto(scipy.misc.imread(FLAGS.input_image), shape=[1] + list(img.shape))
# Call the prediction server
result = stub.Predict(request, 10.0) # 10 secs timeout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment