Skip to content

Instantly share code, notes, and snippets.

@dipanjanS
Created September 20, 2019 10:34
Show Gist options
  • Save dipanjanS/c927d961cdb442e4405eadd98486876e to your computer and use it in GitHub Desktop.
Save dipanjanS/c927d961cdb442e4405eadd98486876e to your computer and use it in GitHub Desktop.
%%time
sample_test_data = test_images
sample_test_labels = test_labels
sample_test_data_processed = np.expand_dims(sample_test_data / 255., axis=3)
data = json.dumps({"signature_name": "serving_default",
"instances": sample_test_data_processed.tolist()})
HEADERS = {'content-type': 'application/json'}
MODEL1_API_URL = 'http://localhost:8501/v1/models/fashion_model_serving/versions/1:predict'
json_response = requests.post(MODEL1_API_URL, data=data, headers=HEADERS)
predictions = json.loads(json_response.text)['predictions']
predictions = np.argmax(np.array(predictions), axis=1)
prediction_labels = [class_names[p] for p in predictions]
len(prediction_labels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment