Skip to content

Commit 701b3b5

Browse files
committed
minor changes batch size and h, w
1 parent 40cfb4f commit 701b3b5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

articles/machine-learning/how-to-inference-onnx-automl-image-models.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ best_child_run.download_file(name='train_artifacts/model.onnx', output_file_path
8787

8888
By default, AutoML for Images supports batch scoring for classification.But object detection and instance segmentation models don't support batch inferencing. In case of batch inference for object detection and instance segmentation, use the following procedure to generate an ONNX model for the required batch size. Models generated for a specific batch size don't work for other batch sizes.
8989

90-
While exporting ONNX models, height and width of the images can be set by the user (choose values closer to training images for better predictions) to generate ONNX models.
91-
92-
9390

9491
```python
9592
from azureml.core.script_run_config import ScriptRunConfig
@@ -127,7 +124,7 @@ For multi-label image classification, the generated ONNX model for the best chil
127124
# [Object detection with Faster R-CNN or RetinaNet](#tab/object-detect-cnn)
128125
```python
129126
arguments = ['--model_name', 'fasterrcnn_resnet34_fpn', # enter the faster rcnn or retinanet model name
130-
'--batch_size', 5, # enter the batch size of your choice
127+
'--batch_size', 8, # enter the batch size of your choice
131128
'--height_onnx', 600, # enter the height of input to ONNX model
132129
'--width_onnx', 800, # enter the width of input to ONNX model
133130
'--experiment_name', experiment_name,
@@ -148,7 +145,7 @@ arguments = ['--model_name', 'fasterrcnn_resnet34_fpn', # enter the faster rcnn
148145

149146
```python
150147
arguments = ['--model_name', 'yolov5', # enter the yolo model name
151-
'--batch_size', 5, # enter the batch size of your choice
148+
'--batch_size', 8, # enter the batch size of your choice
152149
'--height_onnx', 640, # enter the height of input to ONNX model
153150
'--width_onnx', 640, # enter the width of input to ONNX model
154151
'--experiment_name', experiment_name,
@@ -168,7 +165,7 @@ arguments = ['--model_name', 'yolov5', # enter the yolo model name
168165

169166
```python
170167
arguments = ['--model_name', 'maskrcnn_resnet50_fpn', # enter the maskrcnn model name
171-
'--batch_size', 5, # enter the batch size of your choice
168+
'--batch_size', 8, # enter the batch size of your choice
172169
'--height_onnx', 600, # enter the height of input to ONNX model
173170
'--width_onnx', 800, # enter the width of input to ONNX model
174171
'--experiment_name', experiment_name,
@@ -201,7 +198,7 @@ remote_run.wait_for_completion(wait_post_processing=True)
201198

202199
Once the batch model is generated, either download it from **Outputs+logs** > **outputs** manually, or use the following method:
203200
```python
204-
batch_size= 5 # use the batch size used to generate the model
201+
batch_size= 8 # use the batch size used to generate the model
205202
onnx_model_path = 'automl_models/model.onnx' # local path to save the model
206203
remote_run.download_file(name='outputs/model_'+str(batch_size)+'.onnx', output_file_path=onnx_model_path)
207204
```
@@ -458,7 +455,7 @@ def preprocess(image, resize_size, crop_size_onnx):
458455

459456
test_images_path = "automl_models_multi_cls/test_images_dir/*" # replace with path to images
460457
# Select batch size needed
461-
batch_size = 5
458+
batch_size = 8
462459
# you can modify resize_size based on your trained model
463460
resize_size = 256
464461
# height and width will be the same for classification
@@ -517,7 +514,7 @@ def preprocess(image, resize_size, crop_size_onnx):
517514

518515
test_images_path = "automl_models_multi_cls/test_images_dir/*" # replace with path to images
519516
# Select batch size needed
520-
batch_size = 5
517+
batch_size = 8
521518
# you can modify resize_size based on your trained model
522519
resize_size = 256
523520
# height and width will be the same for classification
@@ -607,7 +604,7 @@ def preprocess(image, resize_size, crop_size_onnx):
607604

608605
test_images_path = "automl_models_multi_label/test_images_dir/*" # replace with path to images
609606
# Select batch size needed
610-
batch_size = 5
607+
batch_size = 8
611608
# you can modify resize_size based on your trained model
612609
resize_size = 256
613610
# height and width will be the same for classification
@@ -679,7 +676,7 @@ def preprocess(image, resize_size, crop_size_onnx):
679676

680677
test_images_path = "automl_models_multi_label/test_images_dir/*" # replace with path to images
681678
# Select batch size needed
682-
batch_size = 5
679+
batch_size = 8
683680
# you can modify resize_size based on your trained model
684681
resize_size = 256
685682
# height and width will be the same for classification

0 commit comments

Comments
 (0)