--dynamic_image_size
Applicable Products
All processors
Description
Sets dynamic image size profiles. Applies to the scenario where the resolution of images input for inference is unfixed.
See Also
- Use this option together with --input_shape. This option is mutually exclusive with --dynamic_batch_size and --dynamic_dims.
- When this option is used to set the dynamic image size, --input_format can only be set to NCHW or NHWC. In other format scenarios, use --dynamic_dims.
Arguments
Argument: Dynamic image size, for example, "imagesize1_height,imagesize1_width;imagesize2_height,imagesize2_width".
Format: Enclose the whole argument in double quotation marks (""), and separate profiles by semicolons (;) and that within a profile by commas (,).
Restrictions:
- For the following products, at least two profiles must be set, and a maximum of 100 profiles are supported, that is, (1,100].
Atlas A3 training products /Atlas A3 inference products Atlas A2 training products /Atlas A2 inference products Atlas 200I/500 A2 inference products Atlas inference products Atlas training products - For the
Ascend 950PR /Ascend 950DT , at least two profiles must be set, and a maximum of 256 profiles are supported, that is, (1,256]. - In the scenario where you have set too large image sizes or too many image size profiles, you are advised to run the swapoff -a command to disable the use of swap space as memory to prevent slow operating environment.
Suggestions and Benefits
Too large image sizes or too many image size profiles will cause model conversion failures. If such failure occurs, you are advised to reduce the number of profiles or decrease the profile value.
Example
--input_shape="data:8,3,-1,-1;img_info:8,4,-1,-1" --dynamic_image_size="416,416;832,832"
-1 in --input_shape indicates dynamic image size enabled. The input supports the following shape profiles at ATC build time:
Profile 0: data(8,3,416,416)+img_info(8,4,416,416)
Profile 1: data(8,3,832,832)+img_info(8,4,832,832)
Dependencies and Restrictions
- Option usage:
- Networks that contain dynamic-shape operators (middle layers of the network with unfixed shape) are not supported.
- To use the dynamic image size feature, ensure that the configured profiles are within the valid range supported by the original framework.
- If the dynamic image size is enabled, the sizes of the dataset images used for inference must match the runtime image size.
- If you have set the dynamic image size as well as static AIPP (by setting --insert_op_conf), you must disable the cropping and padding functions, and set src_image_size_w and src_image_size_h to 0 in the configuration file.
- If you have set the dynamic image size as well as dynamic AIPP (by setting --insert_op_conf):
During actual inference, call the aclmdlSetInputAIPP API to set dynamic AIPP parameters. Ensure that cropping and padding are disabled. In this scenario, ensure that the width and height configured by calling aclmdlSetInputAIPP are the same as those configured by calling aclmdlSetDynamicHWSize. That is, both values must be set to the width and height of the maximum dynamic image size profile.
- The offline model generated with this option enables the dynamic image size feature, which may introduce structural differences compared with models from fixed image size scenarios and result in differences in inference performance.
- API usage:
If this option is used to set the dynamic image size during model conversion, you need to perform the following operations before calling the model execution APIs to run an application project for inference:
- Use the aclmdlSetDynamicHWSize API to set the actual image size. The size of the dataset images used for inference must match the specific image size in use.
- If aclmdlSetDynamicHWSize is not called, values are assigned based on the maximum width and height within the dynamic image size range by default during model execution.