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, infer two .jpg images synchronously, obtain the inference results, process the inference results, and outputs the class indexes with the top 5 confidence values.
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 |
Provides sample code to process the model inference result and display the class indexes with top 5 confidences on the device. |
Directory Structure
The directory structure is as follows:
resnet50_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 // Test data, which needs to be deployed by users. │ ├── dog1_1024_683.jpg // Test image data │ └── dog2_1024_683.jpg // Test image data ├── README_CN.md ├── caffe_model // Model deployed by users. │ ├── resnet50.caffemodel // ResNet-50 model │ └── resnet50.prototxt // ResNet-50 network file └── model // Directory generated after the inference model is converted. └── resnet50.om // Model file generated after conversion