Query your AI model
You can make an inference request against the AI model server that is using the ovms-resnet50 model.
-
MicroShift is running.
-
You configured the model-serving runtime.
-
You uploaded your AI model to MicroShift.
-
Make an inference request against the model server that is using the
ovms-resnet50model by running the following command:$ curl \ --data-binary "@./request.json" \ --header "Inference-Header-Content-Length: ${HEADER_LEN}" \ "${DOMAIN}/v2/models/ovms-resnet50/infer" \ --connect-to "${DOMAIN}::${IP}:" > response.jsonExample inferencing output, saved to aresponse.json{ "model_name": "ovms-resnet50", "model_version": "1", "outputs": [{ "name": "1463", "shape": [1, 1000], "datatype": "FP32", "data": [ ....... ]}] }
The contents of
.outputs[0].datawere omitted from the example for brevity.
-
To determine the model’s prediction, get the index of the highest element in the
.outputs[0].datato determine the model’s predicted value by using the following Python script:import json with open('response.json') as f: response = json.load(f) data = response["outputs"][0]["data"] argmax = data.index(max(data)) print(argmax)Example output309In this example, the element labeled
309is the model’s response. -
Validate the output against resnet’s input data, for example:
../../../../demos/common/static/images/bee.jpeg 309
-
Optional. Query the AI model using other images available in the resnet input data.