Surpassing Apple M1, OpenCV 4.7 completes ResNet50 inference in only 3.29ms under Huawei Ascend architecture

Gamingdeputy News on January 18, Intel’s open source computer vision library OpenCV 4.7 was officially released in December last year. The new version brings a new ONNX layer, which greatly improves the convolution performance of the DNN code, and also provides Huawei Ascend CANN backend support for the DNN module.

According to the latest test of the OpenCV China team, based on the acceleration capability of the Ascend heterogeneous computing architecture CANN, the CANN backend was tested with PP-ResNet50, MobileNet and YOLOX in the OpenCV Zoo.It was found that the three models achieved excellent results of 3.29ms, 1.21ms, and 12.80ms respectively under the CANN backend.

At the same time, the inference results of the CANN backend are basically consistent with those of the default CPU backend. Using OpenCV,Users only need to use the following 7 lines of Python code to call the Ascend AI processor concisely without learning the API of CANNto achieve neural network accelerated reasoning (the core is the third and fourth lines of code, and the rest are logic codes for common model reasoning):

import cv2 as cvnet = cv.dnn.readNet("/path/to/model.onnx")net.setPreferableBackend(cv.dnn.DNN_BACKEND_CANN)net.setPreferableTarget(cv.dnn.DNN_TARGET_NPU)input = cv.imread("/path/to/image.jpg")net.setInput(cv.dnn.blobFromImage(input))out = net.forward()

▲ Example code using CANN backend reasoning

Teacher Yu Shiqi from the Computer Department of Southern University of Science and Technology said that OpenCV has been optimized for ARM CPU, such as winograd conv,It takes more than 20ms to complete ResNet50 inference on Apple’s benchmark CPU M1, while Huawei Ascend only takes 3.29ms.

Surpassing Apple M1, OpenCV 4.7 completes ResNet50 inference in only 3.29ms under Huawei Ascend architecture

Ascend CANN (Compute Architecture for Neural Networks) is a heterogeneous computing architecture launched by Huawei for AI scenarios. Shengteng CANN supports Shengsi MindSpore, OpenCV DNN, Flying Paddle Paddle, PyTorch, TensorFlow and other neural network reasoning and training frameworks, and is compatible with a variety of underlying hardware devices.

Surpassing Apple M1, OpenCV 4.7 completes ResNet50 inference in only 3.29ms under Huawei Ascend architecture

×