--dynamic_image_size

Description

Sets dynamic image size profiles. Applies to the scenario where the resolution of images input for inference is unfixed.

See Also

Argument

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: The profile range is (1, 100]. That means at least two profiles should be set, and a maximum of 100 profiles are supported.

Suggestions and Benefits

  • Too large image sizes or too many image size profiles will cause model conversion failures.
  • 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.

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)

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

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 keep the cropping and padding switches off, 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):

      In your inference code, call the aclmdlSetInputAIPP API provided by AscendCL 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, the width and height must be set to the maximum dynamic image size.

      For details about the APIs, see Model Execution.

    • The offline model generated with this option included is configured with the dynamic image size feature, which might have structure differences from that generated without this option and therefore shows different 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 provided by AscendCL to set the runtime image size. The size of the dataset images used for inference must match the runtime 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.

    For details about the APIs, see aclmdlSetDynamicHWSize.