Development Requirement Analysis
Development Purpose
To develop an image classification application to classify two 1024 x 683 .jpg images.
Scenario Analysis
Analyze the required functions of the application and the involved ACL APIs from the following aspects.
Function |
Implementation Analysis |
Key Command and API |
---|---|---|
Model inference |
Select an open-source classification network, for example, the Caffe ResNet-50 network and convert it into an offline model (.om file) that adapts to Ascend AI Processors. |
|
Data preprocessing (including decoding, cropping, resizing, encoding, CSC) |
The ResNet-50 network takes 224 x 224 RGB images only. Therefore, the existing 1024 x 683 .jpg images need to be decoded into the YUV420SP format, resized to 224 x 224, and then converted into the RGB format. |
|
Data postprocessing |
Post-process the model inference result. That is, call the Cast and ArgMaxD operators to identify the class label with the highest confidence score of each image from the inference result. Call the Cast operator to convert the data type of the inference result from float32 to float16, and then call the ArgMaxD operator to identify the class label with the highest confidence score of each image from the inference result. |
|
Data copy |
Copy image from the host to the device for processing and copy the processing result to the host after processing is complete. |
API for data copy: acl.rt.memcpy |