App Running
The sample procedure applies to the following products:
- Atlas 200/300/500 Inference Product
- Atlas Training Series Product
Model Conversion
- Log in to the development environment as the HwHiAiUser user (running user).
- Obtain the ATC tool and set environment variables by referring to ATC Instructions.
- Prepare data.
Obtain the ResNet-50 weight file (.caffemodel) and model file (resnet50.prototxt) from the following link and upload the files to the vdec_resnet50_classification/caffe_model directory in the development environment as the HwHiAiUser user (running user).
- Convert the ResNet-50 network into an offline model (.om file) adapted to the Ascend AI Processor. During model conversion, you need to set CSC parameters to convert YUV420SP images to RGB images.
Go to the vdec_resnet50_classification directory and run the following command. Ascendxxx indicates the Ascend AI Processor version. Replace it with the actual one.
atc --model=caffe_model/resnet50.prototxt --weight=caffe_model/resnet50.caffemodel --framework=0 --output=model/resnet50_aipp --soc_version=Ascendxxx --insert_op_conf=caffe_model/aipp.cfg
- --output: The generated resnet50_aipp.om file is stored in the vdec_resnet50_classification/model directory.
- Before running the atc command, ensure that you have the write permission on the vdec_resnet50_classification directory.
- If the soc_version of the current device cannot be determined, run the npu-smi info command on the server where the NPU driver package is installed and add Ascend information before the queried Name. For example, if the value of Name is xxxyy, the actual soc_version is Ascendxxxyy.
- As the HwHiAiUser running user, upload the sample directory in the development environment to the operating environment.
App Running
- Log in to the operating environment.
- Prepare the input video stream.
- Configure the operating environment by referring to Environment Variable Configuration.
- Run the following command in vdec_resnet50_classification:
python3 ./src/acl_sample.py
- Check the execution result. You should find the following information upon execution success (only part of the information is displayed):
init resource stage: init resource stage success [Model] class Model init resource stage: [Model] create model output dataset: [Model] create model output dataset success [Model] class Model init resource stage success [Dvpp] class Dvpp init resource stage: [Dvpp] class Dvpp init resource stage success [Vdec] class Vdec init resource stage: [Vdec] class Vdec init resource stage success [Vdec] forward index:0 [Vdec] create input stream desc success [Vdec] create output pic desc success [Vdec] vdec_send_frame stage success ...... [Vdec] [_callback] _callback exit success [Vdec] [_thread_func] _thread_func out [Vdec] vdec finish!!! [Dvpp] vpc resize stage: [Dvpp] vpc resize stage success [Model] create model input dataset: [Model] create model input dataset success [Model] execute stage: [Model] execute stage success ========= top5 inference results: ========= label:331 prob: 0.910156 label:330 prob: 0.078308 label:104 prob: 0.009209 label:332 prob: 0.003283 label:350 prob: 0.000005 result: class_label[331],top1[0.910156],top5[1.000000] ...... [Sample] release source stage: [Dvpp] class Dvpp release source success [Model] class Model release source success [Vdec] release resource: [Vdec] release resource success [Sample] release source stage success