How to get prediction from ml rest api if it is an image classification model by keras for real time endpoint?
Background: Model is deployed to an endpoint and it's working. I am trying to get a prediction from the model by submitting an image.
My understanding is Keras model takes images as an array. However, converting an image to array would return a large array and it needs to be passed in the below code as a json body.
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key), 'azureml-model-deployment': 'blue' }
url = 'https://xyz.xyz.inference.ml.azure.com/score'
req = urllib.request.Request(url, body, headers)
try:
response = urllib.request.urlopen(req)
result = response.read()
print(result)
except urllib.error.HTTPError as error:
print("The request failed with status code: " + str(error.code))
# Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
print(error.info())
print(error.read().decode("utf8", 'ignore'))
I have tried adding "GlobalParameters": 1.0 but it did not work at all.
Error message :
The request failed with status code: 424server: azureml-frontdoordate: Fri, 24 Mar 2023 05:59:11 GMTcontent-type: application/jsoncontent-length: 38x-ms-run-function-failed: Truex-ms-server-version: azmlinfsrv/0.8.0x-ms-request-id: 34201170-065b-43af-97ea-7b76fa7ff2ffx-request-id: 34201170-065b-43af-97ea-7b76fa7ff2ffms-azureml-model-error-reason: model_errorms-azureml-model-error-statuscode: 500azureml-model-deployment: blueconnection: close