In [ ]:
# Use the Azure Machine Learning data collector to log various metrics
from azureml.logging import get_azureml_logger
logger = get_azureml_logger()

In [20]:
import cv2
import numpy as np
import json
import requests
np.set_printoptions(threshold=np.nan)

In [27]:
path_to_image = "/tmp/data/mnist_png/testing/7/0.png"
img_width, img_height = 28, 28

In [28]:
img = cv2.imread(path_to_image)
img = cv2.resize(img, (img_width, img_height))
img.shape


Out[28]:
(28, 28, 3)

In [29]:
input_array = np.array(img).reshape((img_width,img_height,3))
input_array = np.expand_dims(input_array, axis=0)
input_array.shape


Out[29]:
(1, 28, 28, 3)

In [30]:
type(input_array)


Out[30]:
numpy.ndarray

In [31]:
url = "http://127.0.0.1:32773/score"
headers = {'content-type': 'application/json'}
json_data = "{\"input_array\": " + str(input_array.tolist()) + "}"

In [32]:
r = requests.post(url, data=json_data, headers=headers)
r.json()


Out[32]:
'7'

In [ ]:


In [ ]:


In [ ]: