Skip to content

Instantly share code, notes, and snippets.

@eavidan
Last active August 5, 2018 09:17
Show Gist options
  • Save eavidan/07928337e2859bf8fa607f5693ee4a89 to your computer and use it in GitHub Desktop.
Save eavidan/07928337e2859bf8fa607f5693ee4a89 to your computer and use it in GitHub Desktop.
import pickle
import numpy as np
import requests
host = 'localhost'
port = '8501'
batch_size = 1
image_path = "./mnist_image.pkl"
model_name = 'mnist'
signature_name = 'predict_images'
with open(image_path, 'rb') as f:
image = pickle.load(f)
batch = np.repeat(image, batch_size, axis=0).tolist()
json = {
"signature_name": signature_name,
"instances": batch
}
response = requests.post("http://%s:%s/v1/models/mnist:predict" % (host, port), json=json)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment