Function: set_aipp_by_input_index
Applicability
|
Product |
Supported (√/x) |
|---|---|
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
Function Usage
Sets the dynamic AIPP attributes for model inference based on an input index.
Dynamic AIPP provides the following operations. They are executed in the exact sequence.
- Cropping
- Color space conversion
- Mean subtraction/Normalization
- Padding
Prototype
- C Prototype
1aclError aclmdlSetAIPPByInputIndex(uint32_t modelId, aclmdlDataset *dataset, size_t index, const aclmdlAIPP *aippParmsSet)
- Python Function
1ret = acl.mdl.set_aipp_by_input_index(model_id, dataset_in, index, aipp)
Parameter Description
|
Parameter |
Description |
|---|---|
|
model_id |
Int, model ID. You can obtain the model ID after the model is successfully loaded by calling the following APIs: |
|
dataset_in |
Int, pointer address of the input data for model inference. Data of type aclmdlDataset describes the input data for model inference, while data of type aclDataBuffer describes the input buffer size and address. For details, see aclmdlDataset. |
|
index |
Int, index of the dynamic AIPP input. If the input is not associated with a dynamic AIPP input, an error is reported. Call acl.mdl.get_aipp_type to query whether a specified model input has an associated dynamic AIPP input. If yes, the index argument passed to this API call is the same as that of acl.mdl.get_aipp_type. If no, you do not need to set dynamic AIPP attributes. |
|
aipp |
Int, pointer address of the dynamic AIPP parameter object. acl.mdl.create_aipp is called in advance to create data of the aclmdlAIPP type. |
Return Value Description
|
Return Value |
Description |
|---|---|
|
ret |
Int, error code: 0 on success; else, failure. |
Restrictions
-
The image size after dynamic AIPP processing must be the same as that defined by the input shape required by the original model.
-
In batched inference scenarios, the image size after dynamic AIPP is calculated based on the configuration of each batch. After dynamic AIPP, the output image size must be consistent across batches. Table 1 describes the formulas for calculating the width and height of the output image.
-
After image cropping, resizing, or padding, the width and height of the image are verified as follows. aippOutputW and aippOutputH indicate the width and height of the output image, respectively. Other parameters are the input parameters of the acl.mdl.set_aipp_srcImage_size, acl.mdl.set_aipp_scf_params, acl.mdl.set_aipp_crop_params and acl.mdl.set_aipp_padding_params APIs. See Table 1.
Table 1 Formulas for calculating the output image size Cropping
Resizing
Padding
Output Width and Height
No
No
No
aippOutputW = srcImageSizeW
aippOutputH = srcImageSizeH
Yes
No
No
aippOutputW = cropSizeW
aippOutputH = cropSizeH
Yes
Yes
No
aippOutputW = scfOutputSizeW
aippOutputH = scfOutputSizeH
Yes
No
Yes
aippOutputW = cropSizeW + paddingSizeLeft + paddingSizeRight
aippOutputH = cropSizeH + paddingSizeTop + paddingSizeBottom
No
No
Yes
aippOutputW = srcImageSizeW + paddingSizeLeft + paddingSizeRight
aippOutputH = srcImageSizeH + paddingSizeTop + paddingSizeBottom
No
Yes
Yes
aippOutputW = scfOutputSizeW + paddingSizeLeft + paddingSizeRight
aippOutputH = scfOutputSizeH + paddingSizeTop + paddingSizeBottom
No
Yes
No
aippOutputW = scfOutputSizeW
aippOutputH = scfOutputSizeH
Yes
Yes
Yes
aippOutputW = scfOutputSizeW + paddingSizeLeft + paddingSizeRight
aippOutputH = scfOutputSizeH + paddingSizeTop + paddingSizeBottom