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. In the sample, load the .om file and perform n (an app parameter configured by the user. It is defaulted to 4 and can be set by the --execute_times parameter.) times of asynchronous inference on two .jpg images. Then, process the obtained n inference results, and output the class indexes with the top 5 confidence values of each image.
Main APIs
The following table lists the main APIs.
A device indicates the neural-network processing unit (NPU) on the board environment. For the SoC, there is only one device.
Initialization |
|
|---|---|
Device management |
|
Stream management |
|
Memory management |
|
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 |
|
Data postprocessing |
The sample processes the model inference result and prints the class indexes with the top 1 confidence values on the terminal. |
Directory Structure
The directory structure is as follows:
resnet50_async_imagenet_classification ├──scripts │ ├── host_version.conf // Version number configuration file │ └── testcase_300.sh // Run script ├──src │ ├── acl_net.py // Running file │ └── constant.py // Constant definition ├── data │ ├── fusion_result.json // File generated after atc conversion, which records the fused operator information. │ ├── dog1_1024_683.jpg // Test image data │ └── dog2_1024_683.jpg // Test image data ├── caffe_model │ ├── resnet50.caffemodel // ResNet-50 model │ └── resnet50.prototxt // ResNet-50 network file └── model // Directory generated after ATC conversion │ └── resnet50.om // Model file generated after conversion └── README_CN.md