Skip to content

Commit fa4679c

Browse files
committed
updated with code reference and reviews
1 parent 5eb17c2 commit fa4679c

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

articles/machine-learning/reference-automl-images-schema.md

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -256,59 +256,29 @@ The following is the input format needed to generate predictions on any task usi
256256
}
257257
```
258258

259-
This json is a dictionary with outer key `input_data` and inner keys `columns`, `data` as described in the following table. The endpoint accepts json string as input in the above format so that this json string can be decoded to json to create a dataframe of samples required by scoring script. Each input image in the `request_json["input_data"]["data"]` defined in the json format above is a [base64 encoded string](https://docs.python.org/3/library/base64.html#base64.encodebytes).
259+
This json is a dictionary with outer key `input_data` and inner keys `columns`, `data` as described in the following table. The endpoint accepts a json string in the above format and converts it into a dataframe of samples required by the scoring script. Each input image in the `request_json["input_data"]["data"]` section of the json is a [base64 encoded string](https://docs.python.org/3/library/base64.html#base64.encodebytes).
260260

261261

262262
| Key | Description |
263263
| -------- |----------|
264264
| `input_data`<br> (outer key) | It is an outer key in json request. `input_data` is a dictionary that accepts input image samples <br>`Required, Dictionary` |
265-
| `columns`<br> (inner key) | Column names to be used to create dataframe in scoring script. It accepts only one column with `image` as column name.<br>`Required, List` |
265+
| `columns`<br> (inner key) | Column names to use to create dataframe. It accepts only one column with `image` as column name.<br>`Required, List` |
266266
| `data`<br> (inner key) | List of base64 encoded images <br>`Required, List`|
267267

268268

269269
After we [deploy the mlflow model](how-to-auto-train-image-models.md#register-and-deploy-model), we can use the following code snippet to get predictions for all tasks.
270270

271+
[!Notebook-python[] (~/azureml-examples-v2samplesreorg/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=create_inference_request)]
271272

272-
```python
273-
# Get the details for online endpoint
274-
endpoint = ml_client.online_endpoints.get(name=online_endpoint_name)
275-
276-
# Create request json
277-
import base64
278-
import json
279-
280-
sample_image = "./test_image.jpg"
281-
282-
def read_image(image_path):
283-
with open(image_path, "rb") as f:
284-
return f.read()
285-
286-
request_json = {
287-
"input_data": {
288-
"columns": ["image"],
289-
"data": [base64.encodebytes(read_image(sample_image)).decode("utf-8")],
290-
}
291-
}
292-
293-
request_file_name = "sample_request_data.json"
294-
295-
with open(request_file_name, "w") as request_file:
296-
json.dump(request_json, request_file)
297-
298-
resp = ml_client.online_endpoints.invoke(
299-
endpoint_name=online_endpoint_name,
300-
deployment_name=deployment.name,
301-
request_file=request_file_name,
302-
)
303-
predictions = json.loads(resp)
304-
```
273+
[!Notebook-python[] (~/azureml-examples-v2samplesreorg/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=dump_inference_request)]
305274

275+
[!Notebook-python[] (~/azureml-examples-v2samplesreorg/sdk/python/jobs/automl-standalone-jobs/automl-image-object-detection-task-fridge-items/automl-image-object-detection-task-fridge-items.ipynb?name=invoke_inference)]
306276

307277
### Output format
308278

309279
Predictions made on model endpoints follow different structure depending on the task type. This section explores the output data formats for multi-class, multi-label image classification, object detection, and instance segmentation tasks.
310280

311-
The following schemas are defined for the case of one input image.
281+
The following schemas are applicable when the input request contains one image.
312282

313283
#### Image classification
314284

0 commit comments

Comments
 (0)