Sample Overview
Function Usage
This sample shows how to classify images based on the Caffe ResNet-50 network (single input with batch size = 1).
Convert the model file of the Caffe ResNet-50 network into an offline model (.om file) adapted to the Ascend AI Processor. Load the .om file, decode an H.265 video stream (containing only one frame) cyclically for 10 times to obtain 10 YUV420SP NV12 images, resize the 10 images, and perform inference on the resized images. Process the inference results and output the class indexes with the top confidence values and the sum of the top 5 confidence values.
During model conversion, set CSC parameters to convert YUV420SP images into RGB images to meet the input requirements of the model.
Main APIs
The following table lists the main APIs.
Initialization |
|
|---|---|
Device management |
|
Stream management |
|
Memory management |
Call acl.rt.malloc_host to allocate memory on the host.
If device memory is needed to store the input or output data before media data processing, call acl.media.dvpp_malloc to allocate memory and acl.media.dvpp_free to deallocate memory. |
Data transfer |
If your app runs on the host, call the acl.rt.memcpy API.
Data transfer is not required if your app runs in the board environment. |
Model inference |
|
Directory Structure
The directory structure is as follows:
vdec_resnet50_classification ├──scripts │ ├── host_version.conf // Version number configuration file. │ └── testcase_300.sh // Run script. ├──src │ ├── acl_dvpp.py // Image resizing implementation file │ ├── acl_model.py // Model inference implementation file │ ├── acl_sample.py // Running file │ ├── acl_util.py // Implementation file of tool functions │ ├── acl_vdec.py // Video decoding implementation file │ └── constant.py // Constant definition ├── data ├── README_CN.md │ └── vdec_h265_1frame_rabbit_1280x720.h265 // Video file to be processed by the user, which is obtained by the user. ├── caffe_model // Model deployed by users. │ ├── aipp.cfg // Model configuration data. │ ├── resnet50.caffemodel // ResNet-50 model │ └── resnet50.prototxt // ResNet-50 network file └── model // Directory generated after the inference model is converted. └── resnet50_aipp.om // Model file generated after conversion.