When the JPEGD, VPC, and model inference functions are cascaded, the possible issues and countermeasures are as follows:
Width stride x height stride of the JPEGD output image must be a multiple of 128 x 16, so there are some invalid paddings. Before calling acldvppVpcResizeAsync, call acldvppSetPicDescWidth and acldvppSetPicDescHeight to correctly set the original width and height of the input image, based on which VPC automatically crops and resizes the image to eliminate the impact of invalid data on image accuracy.
To improve model inference accuracy, you are advised to write the code logic by referring to the positive examples shown in Figure 1 and Figure 2.
According to the negative example in Figure 1, after JPEGD decoding, the aligned width and height are directly sent to VPC. As a result, the input image for model inference has invalid data, which may affect the accuracy.
For details about the API call sequences of JPEGD and VPC, see JPEGD API Call Sequence and VPC API Call Sequence.
You can call acldvppVpcCropAsync for image cropping and acldvppVpcResizeAsync for image resizing. acldvppVpcCropAsync also applies to the scenario where image cropping and resizing are cascaded, which provides better performance.
For example, as shown in Figure 2, the output image is 416 x 416, the paste ROI is 240 x 416, and the left offset of the paste ROI relative to the output canvas is (416 – 240)/2 = 88. However, 88 is not a multiple of 16 and needs to be rounded up to 96. In this case, d1 should be calculated as d2 – 96, instead of d2 – 88.
If hardware-based AIPP is required to perform CSC, the source image format in the AIPP CSC configuration must be the same as the VPC output format. Assume that the VPC output format is YUV420SP. If YVU420SP to RGB888 CSC is configured, model inference will suffer accuracy drop.
For the API call sequence of model inference, see Developing a Basic Inference App.
For details about the CSC configuration, see ATC Instructions.
To verify whether the accuracy meets the requirements on Ascend, it is recommended that data preprocessing before model inference be the same as that during model training. For details, see the sample code in the ModelZoo repository.