日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

NXP iMX8基于eIQ框架测试Machine Learning

發布時間:2023/12/10 编程问答 48 豆豆
生活随笔 收集整理的這篇文章主要介紹了 NXP iMX8基于eIQ框架测试Machine Learning 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

By Toradex秦海

1).?簡介

隨著嵌入式處理器性能的提升甚至一些嵌入式處理器已經開始集成針對人工智能和機器學習的硬件加速單元NPU,機器學習應用在嵌入式邊緣設備的應用也慢慢展現。為此,NXP也發布了eIQ for i.MX軟件工具包,用于在NXP的i.MX系列嵌入式處理器上面來支持目前比較常見的各種機器學習推理引擎,比如TensorFlow、Caffe等,具體的支持情況可以參考下圖,其中ArmNN、TensorFlowLite、ONNX可以支持GPU/NPU硬件加速,而OpenCV和PyTorch目前只支持在CPU運行。

?

NXP eIQ協議棧通過Neural Network Runtime (NNRT)模塊來對不同的前端Runtime進行硬件加速支持,具體的架構可以參考下圖,對于很多機器學習算法場景,通過硬件加速引擎可以很大提升算法推理性能。

?

本文的演示的平臺來自于Toradex Apalis iMX8 ARM嵌入式平臺,這是一個基于NXP iMX8QM ARM處理器,支持Cortex-A72+A53和Coretex-M4架構的計算機模塊平臺。

?

?

2).?準備

a).?Apalis iMX8QM?4GB WB IT ARM核心版配合Ioxra?載板,連接調試串口UART1(載板X22)到開發主機方便調試。載板連接HDMI顯示器。

?

?

3). Apalis iMX8 Ycoto Linux?編譯部署以及配置

a). Apalis iMX8 Ycoto Linux?通過Ycoto/Openembedded?框架編譯,具體的配置方法請參考這里,參考如下修改后編譯Reference-Multimedia image鏡像

./ iMX8 Ycoto layer?中默認沒有包含NXP Machine Learning和OpenCV 4.4.0版本支持,因此首先需要通過下面修改添加相關layer,詳細的NXP Ycoto指南請參考i.MX Yocto Project User's Guide Rev. L5.4.70_2.3.0

-------------------------------

### download related layers from NXP official repository

$ repo init -u?https://source.codeaurora.org/external/imx/imx-manifest?-b imx-linux-zeus -m imx-5.4.70-2.3.0.xml

$ repo sync

$ DISTRO=fsl-imx-wayland MACHINE=imx8qmmek source imx-setup-release.sh -b build

?

### copy mechine learning layer meta-ml to Toradex ycoto environment

$ cp -r …/sources/meta-imx/meta-ml …/oe-core/layers/

?

### modify meta-ml layer …/layers/meta-ml/conf/layer.conf file to support ycoto dunfell

--- a/layers/meta-ml/conf/layer.conf??????? 2021-03-03 15:50:59.718815084 +0800

+++ b/layers/meta-ml/conf/layer.conf???? 2021-03-03 16:55:46.791158625 +0800

@@ -8,4 +8,4 @@

?BBFILE_COLLECTIONS += "meta-ml"

?BBFILE_PATTERN_meta-ml := "^${LAYERDIR}/"

?BBFILE_PRIORITY_meta-ml = "8"

-LAYERSERIES_COMPAT_meta-ml = "warrior zeus"

+LAYERSERIES_COMPAT_meta-ml = "warrior zeus dunfell"

?

### copy opencv 4.4.0 related to Toradex ycoto environment

$ cp -r …/sources/meta-imx/meta-bsp/recipes-support/opencv/ …/oe-core/layers/meta-toradex-nxp/recipes-support/opencv/

?

### modify build/conf/bblayer.conf to add above extra layers

--- a/build/conf/bblayers.conf???

+++ b/build/conf/bblayers.conf???

@@ -24,6 +24,9 @@

?? ${TOPDIR}/../layers/meta-openembedded/meta-python \

?? ${TOPDIR}/../layers/meta-freescale-distro \

?? ${TOPDIR}/../layers/meta-toradex-demos \

+? ${TOPDIR}/../layers/meta-ml \

?? ${TOPDIR}/../layers/meta-qt5 \

?? \

?? \

-------------------------------

?

./?修改?local.conf,增加mechine learning?相關支持

-------------------------------

### add python and opencv support ###

+IMAGE_INSTALL_append = " python3 python3-pip opencv python3-opencv python3-pillow"

?

### add eIQ support ###

+IMAGE_INSTALL_append = " arm-compute-library nn-imx tensorflow-lite armnn onnxruntime"

+PACKAGECONFIG_append_pn-opencv_mx8 = " dnn jasper qt5 test"

### remove opencl conflict ###

+PACKAGECONFIG_remove_pn-opencv_mx8 = "opencl"

+PACKAGECONFIG_remove_pn-arm-compute-library = "opencl"

?

### option, add onnxruntime and armnn dev support to SDK ###

+TOOLCHAIN_TARGET_TASK_append += " onnxruntime-dev armnn-dev "

?

ACCEPT_FSL_EULA = "1"

-------------------------------

?

./?編譯image和SDK

-------------------------------

# compile Reference-Multimedia image

$ bitbake bitbake tdx-reference-multimedia-image

?

# compile SDK

bitbake tdx-reference-multimedia-image -c populate_sdk

-------------------------------

?

b). Ycoto Linux image部署

參考這里通過Toradex Easy installer將上面編譯好的image更新部署到模塊,目前最新穩定版本為Ycoto Linux V5.1,最新測試版本為Ycoto Linux V5.2

?

?

4). TensorFlow Lite?測試

a). NXP iMX8 eIQ TensorFlow Lite?支持特性和協議棧框圖如下

./ TensorFlow Lite v2.3.1

./ Multithreaded computation with acceleration using Arm Neon SIMD instructions on Cortex-A cores

./ Parallel computation using GPU/NPU hardware acceleration (on shader or convolution units)

./ C++ and Python API (supported Python version 3)

./ Per-tensor and Per-channel quantized models support

?

b).?示例應用測試

./ Image預裝的TensorFlow Lite測試示例應用位置

/usr/bin/tensorflow-lite-2.3.1/examples

?

./?基于mobilenet model測試?“label_image”示例應用

-------------------------------

$ cd /usr/bin/tensorflow-lite-2.3.1/examples/

?

### Run on CPU

$ ./label_image -m mobilenet_v1_1.0_224_quant.tflite -i grace_hopper.bmp -l labels.txt

Loaded model mobilenet_v1_1.0_224_quant.tflite

resolved reporter

invoked

average time: 44.999 ms

0.780392: 653 military uniform

0.105882: 907 Windsor tie

0.0156863: 458 bow tie

0.0117647: 466 bulletproof vest

0.00784314: 835 suit

?

### Run with GPU acceleration

$ ./label_image -m mobilenet_v1_1.0_224_quant.tflite -i grace_hopper.bmp -l labels.txt -a 1

Loaded model mobilenet_v1_1.0_224_quant.tflite

resolved reporter

INFO: Created TensorFlow Lite delegate for NNAPI.

Applied NNAPI delegate.

invoked

average time: 13.103 ms

0.784314: 653 military uniform

0.105882: 907 Windsor tie

0.0156863: 458 bow tie

0.0117647: 466 bulletproof vest

0.00784314: 668 mortarboard

?

### TensorFlow Lite Python API predefined example script run, no option to choose CPU or GPU, run with GPU acceleration by default if libneuralnetworks.so or

libneuralnetworks.so.1 is found in the /usr/lib directory, otherwise run on CPU

$ python3 label_image.py

INFO: Created TensorFlow Lite delegate for NNAPI.

Applied NNAPI delegate.

Warm-up time: 5052.5 ms

?

Inference time: 12.7 ms

?

0.674510: military uniform

0.129412: Windsor tie

0.039216: bow tie

0.027451: mortarboard

0.019608: bulletproof vest

-------------------------------

?

c).?更多示例和benchmark測試,C++ API應用開發以及當前eIQ對于TensorFlow Lite不同模型的限制等更多信息可以參考NXP i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0 Chapter 3 TensorFlow Lite,從上面簡單測試可以看出NPU加速下mobilenet?模型要比CPU運行性能更好。

?

?

5). Arm Compute Library?測試

a). ACL(ARM-Compute Library)是專為ARM CPU & GPU優化設計的計算機視覺和機器學習庫,基于NEON & OpenCL支持的?SIMD?技術,但在iMX8平臺目前只支持CPU NEON加速,另外因為其為ARM NN架構的計算引擎,因此一般來說建議直接使用ARM NN。NXP iMX8 eIQ ACL支持特性如下

./ Arm Compute Library 20.02.01

./ Multithreaded computation with acceleration using Arm Neon SIMD instructions on Cortex-A cores

./ C++ API only

./ Low-level control over computation

?

b).?示例應用測試

./ Image預裝的ACL測試示例應用位置

/usr/share/arm-compute-library/build/examples

?

./ MobileNet v2 DNN model,隨機輸入量測試

-------------------------------

$ cd /usr/share/arm-compute-library/build/examples

?

$ ./graph_mobilenet_v2

Threads : 1

Target : NEON

Data type : F32

Data layout : NHWC

Tuner enabled? : false

Cache enabled? : false

Tuner mode : Normal

Tuner file :

Fast math enabled? : false

?

Test passed

-------------------------------

?

c).?更多示例測試和參數說明可以參考NXP i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0 Chapter 4 Arm Compute Library。

?

?

6). Arm NN?測試

a). Arm NN是適用于CPU,GPU和NPU的開源推理引擎,該軟件橋接了現有神經網絡框架(例如?TensorFlow?、TensorFlow Lite、Caffe或?ONNX)與在嵌入式?Linux?平臺上運行的底層處理硬件(例如?CPU、GPU?或NPU)。這樣,開發人員能夠繼續使用他們首選的框架和工具,經?Arm NN?無縫轉換結果后可在底層平臺上運行,NXP iMX8 eIQ ARM NN支持特性和協議棧框圖如下

./ Arm NN 20.02.01

./ Multithreaded computation with acceleration using Arm Neon SIMD instructions on Cortex-A cores provided by the ACL

Neon backend

./ Parallel computation using GPU/NPU hardware acceleration (on shader or convolution units) provided by the VSI

NPU backend

./ C++ and Python API (supported Python version 3)

./ Supports multiple input formats (TensorFlow, TensorFlow Lite, Caffe, ONNX)

./ Off-line tools for serialization, deserialization, and quantization (must be built from source)

?

b). Apalis iMX8 $Home?目錄下創建如下測試使用目錄以供后續測試使用

-------------------------------

$ mkdir ArmnnTests

$ cd ArmnnTests

$ mkdir data

$ mkdir models

-------------------------------

?

c). Caffe示例應用測試

./ Image包含如下ARM NN Caffe模型測試示例,本文隨機選擇CaffeAlexNet-Armnn進行測試

/usr/bin/CaffeAlexNet-Armnn

/usr/bin/CaffeCifar10AcrossChannels-Armnn

/usr/bin/CaffeInception_BN-Armnn

/usr/bin/CaffeMnist-Armnn

/usr/bin/CaffeResNet-Armnn

/usr/bin/CaffeVGG-Armnn

/usr/bin/CaffeYolo-Armnn

?

./?部署模型和輸入數據文件到模塊

-------------------------------

###?從這里下載,bvlc_alexnet_1.caffemodel?模型文件,部署到?Apalis iMX8 ~/ArmnnTests/models;shark.jpg?輸入文件,部署到Apalis iMX8 ~/ArmnnTests/data

$ cd ArmnnTests

?

### Run with C++ backend, CPU without NEON

$ CaffeAlexNet-Armnn --data-dir=data --model-dir=models --compute=CpuRef

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 2 with value: 0.706227

Info: Top(2) prediction is 0 with value: 1.26575e-05

Info: Total time for 1 test cases: 15.842 seconds

Info: Average time per test case: 15841.653 ms

Info: Overall accuracy: 1.000

?

### Run with ACL NEON backend, CPU with NEON

$ CaffeAlexNet-Armnn --data-dir=data --model-dir=models --compute=CpuAcc

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 2 with value: 0.706226

Info: Top(2) prediction is 0 with value: 1.26573e-05

Info: Total time for 1 test cases: 0.237 seconds

Info: Average time per test case: 236.571 ms

Info: Overall accuracy: 1.000

?

### Run with GPU/NPU backend

$ CaffeAlexNet-Armnn --data-dir=data --model-dir=models --compute=VsiNpu

Info: ArmNN v20200200

?

, size = 618348Warn-Start NN executionInfo: = Prediction values for test #0

Info: Top(1) prediction is 2 with value: 0.706227

Info: Top(2) prediction is 0 with value: 1.26573e-05

Info: Total time for 1 test cases: 0.304 seconds

Info: Average time per test case: 304.270 ms

Info: Overall accuracy: 1.000

-------------------------------

?

d). TensorFlow示例應用測試

./ Image包含如下ARM NN TensorFlow模型測試示例,本文隨機選擇TfInceptionV3-Armnn進行測試

/usr/bin/TfCifar10-Armnn

/usr/bin/TfInceptionV3-Armnn

/usr/bin/TfMnist-Armnn

/usr/bin/TfMobileNet-Armnn

/usr/bin/TfResNext-Armnn

?

./?部署模型和輸入數據文件到模塊

-------------------------------

###?從這里下載,inception_v3_2016_08_28_frozen.pb?模型文件,部署到?Apalis iMX8 ~/ArmnnTests/models;shark.jpg, Dog.jpg, Cat.jpg?輸入文件,部署到Apalis iMX8 ~/ArmnnTests/data

$ cd ArmnnTests

?

### Run with C++ backend, CPU without NEON

$ TfInceptionV3-Armnn --data-dir=data --model-dir=models --compute=CpuRef

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 0.454895

Info: Top(2) prediction is 160 with value: 0.00278846

Info: Top(3) prediction is 131 with value: 0.000483914

Info: Top(4) prediction is 56 with value: 0.000304587

Info: Top(5) prediction is 27 with value: 0.000220489

Info: = Prediction values for test #1

Info: Top(1) prediction is 283 with value: 0.481285

Info: Top(2) prediction is 282 with value: 0.268979

Info: Top(3) prediction is 151 with value: 0.000375892

Info: Top(4) prediction is 24 with value: 0.00036751

Info: Top(5) prediction is 13 with value: 0.000330214

Info: = Prediction values for test #2

Info: Top(1) prediction is 3 with value: 0.986568

Info: Top(2) prediction is 0 with value: 1.51615e-05

Info: Total time for 3 test cases: 1477.627 seconds

Info: Average time per test case: 492542.205 ms

Info: Overall accuracy: 1.000

?

### Run with ACL NEON backend, CPU with NEON

$ TfInceptionV3-Armnn --data-dir=data --model-dir=models --compute=CpuAcc

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 0.454888

Info: Top(2) prediction is 160 with value: 0.00278851

Info: Top(3) prediction is 131 with value: 0.00048392

Info: Top(4) prediction is 56 with value: 0.000304589

Info: Top(5) prediction is 27 with value: 0.000220489

Info: = Prediction values for test #1

Info: Top(1) prediction is 283 with value: 0.481286

Info: Top(2) prediction is 282 with value: 0.268977

Info: Top(3) prediction is 151 with value: 0.000375891

Info: Top(4) prediction is 24 with value: 0.000367506

Info: Top(5) prediction is 13 with value: 0.000330212

Info: = Prediction values for test #2

Info: Top(1) prediction is 3 with value: 0.98657

Info: Top(2) prediction is 0 with value: 1.51611e-05

Info: Total time for 3 test cases: 4.541 seconds

Info: Average time per test case: 1513.509 ms

Info: Overall accuracy: 1.000

?

### Run with GPU/NPU backend

$ TfInceptionV3-Armnn --data-dir=data --model-dir=models --compute=VsiNpu

Info: ArmNN v20200200

?

, size = 1072812Warn-Start NN executionInfo: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 0.454892

Info: Top(2) prediction is 160 with value: 0.00278848

Info: Top(3) prediction is 131 with value: 0.000483917

Info: Top(4) prediction is 56 with value: 0.000304589

Info: Top(5) prediction is 27 with value: 0.00022049

Warn-Start NN executionInfo: = Prediction values for test #1

Info: Top(1) prediction is 283 with value: 0.481285

Info: Top(2) prediction is 282 with value: 0.268977

Info: Top(3) prediction is 151 with value: 0.000375891

Info: Top(4) prediction is 24 with value: 0.000367508

Info: Top(5) prediction is 13 with value: 0.000330214

Warn-Start NN executionInfo: = Prediction values for test #2

Info: Top(1) prediction is 3 with value: 0.986568

Info: Top(2) prediction is 0 with value: 1.51615e-05

Info: Total time for 3 test cases: 5.617 seconds

Info: Average time per test case: 1872.355 ms

Info: Overall accuracy: 1.000

-------------------------------

?

e). ONNX示例應用測試

./ Image包含如下ARM NN ONNX模型測試示例,本文隨機選擇OnnxMobileNet-Armnn進行測試

/usr/bin/OnnxMnist-Armnn

/usr/bin/OnnxMobileNet-Armnn

?

./?部署模型和輸入數據文件到模塊

-------------------------------

###?從這里下載,mobilenetv2-1.0.onnx?模型文件,部署到?Apalis iMX8 ~/ArmnnTests/models;shark.jpg, Dog.jpg, Cat.jpg?輸入文件,部署到Apalis iMX8 ~/ArmnnTests/data

$ cd ArmnnTests

?

### Run with C++ backend, CPU without NEON

$ OnnxMobileNet-Armnn --data-dir=data --model-dir=models --compute=CpuRef

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 17.1507

Info: Top(2) prediction is 207 with value: 15.3666

Info: Top(3) prediction is 159 with value: 11.0918

Info: Top(4) prediction is 151 with value: 5.26187

Info: Top(5) prediction is 112 with value: 4.09802

Info: = Prediction values for test #1

Info: Top(1) prediction is 281 with value: 13.6938

Info: Top(2) prediction is 43 with value: 6.8851

Info: Top(3) prediction is 39 with value: 6.33825

Info: Top(4) prediction is 24 with value: 5.8566

Info: Top(5) prediction is 8 with value: 3.78032

Info: = Prediction values for test #2

Info: Top(1) prediction is 2 with value: 22.6968

Info: Top(2) prediction is 0 with value: 5.99574

Info: Total time for 3 test cases: 163.569 seconds

Info: Average time per test case: 54523.023 ms

Info: Overall accuracy: 1.000

?

### Run with ACL NEON backend, CPU with NEON

$ OnnxMobileNet-Armnn --data-dir=data --model-dir=models --compute=CpuAcc

Info: ArmNN v20200200

?

Info: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 17.1507

Info: Top(2) prediction is 207 with value: 15.3666

Info: Top(3) prediction is 159 with value: 11.0918

Info: Top(4) prediction is 151 with value: 5.26187

Info: Top(5) prediction is 112 with value: 4.09802

Info: = Prediction values for test #1

Info: Top(1) prediction is 281 with value: 13.6938

Info: Top(2) prediction is 43 with value: 6.88511

Info: Top(3) prediction is 39 with value: 6.33825

Info: Top(4) prediction is 24 with value: 5.8566

Info: Top(5) prediction is 8 with value: 3.78032

Info: = Prediction values for test #2

Info: Top(1) prediction is 2 with value: 22.6968

Info: Top(2) prediction is 0 with value: 5.99574

Info: Total time for 3 test cases: 1.222 seconds

Info: Average time per test case: 407.494 ms

Info: Overall accuracy: 1.000

?

### Run with GPU/NPU backend

$ OnnxMobileNet-Armnn --data-dir=data --model-dir=models --compute=VsiNpu

Info: ArmNN v20200200

?

, size = 602112Warn-Start NN executionInfo: = Prediction values for test #0

Info: Top(1) prediction is 208 with value: 8.0422

Info: Top(2) prediction is 207 with value: 7.98566

Info: Top(3) prediction is 159 with value: 6.76481

Info: Top(4) prediction is 151 with value: 4.16534

Info: Top(5) prediction is 60 with value: 2.40269

Warn-Start NN executionInfo: = Prediction values for test #1

Info: Top(1) prediction is 287 with value: 5.98563

Info: Top(2) prediction is 24 with value: 5.49244

Info: Top(3) prediction is 8 with value: 2.24259

Info: Top(4) prediction is 7 with value: 1.36127

Info: Top(5) prediction is 5 with value: -1.69145

Error: Prediction for test case 1 (287) is incorrect (should be 281)

Warn-Start NN executionInfo: = Prediction values for test #2

Info: Top(1) prediction is 2 with value: 11.099

Info: Top(2) prediction is 0 with value: 3.42508

Info: Total time for 3 test cases: 0.258 seconds

Info: Average time per test case: 86.134 ms

Error: One or more test cases failed

-------------------------------

?

f).?除了上述推理引擎前端,TensorFlow Lite也是支持的,更多示例測試和參數說明以及ARMNN C++ API/Python API開發流程可以參考NXP i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0 Chapter 5 Arm NN。

?

?

7). ONNX?測試

a). ONNX也是一款開源的機器學習推理引擎,NXP iMX8 eIQ ONNX支持特性和協議棧框圖如下

./ ONNX Runtime 1.1.2

./ Multithreaded computation with acceleration using Arm Neon SIMD instructions on Cortex-A cores provided by the ACL and Arm NN execution providers

./ Parallel computation using GPU/NPU hardware acceleration (on shader or convolution units) provided by the VSI NPU execution provider

./ C++ and Python API (supported Python version 3)

?

b).?示例應用測試

./ ONNX Runtime?提供了一個onnx_test_runner?(BSP以及預裝于/usr/bin)用于運行ONNX model zoo提供的測試模型,下面幾個模型是在iMX8 eIQ測試過的模型

MobileNet v2, ResNet50 v2, ResNet50 v1, SSD Mobilenet v1, Yolo v3

?

./ MobileNet v2?模型測試

-------------------------------

###?從這里下載模型文件壓縮包,然后在Apalis iMX8設備上$Home?目錄解壓出文件夾?mobilenetv2-7

$ cd /home/root/

### Run with ARMNN backend with CPU NEON

$ onnx_test_runner -j 1 -c 1 -r 1 -e armnn ./mobilenetv2-7/

…[E:onnxruntime:Default, runner.cc:217 operator()] Test mobilenetv2-7 finished in 0.907 seconds, t

result:

??????? Models: 1

??????? Total test cases: 3

??????????????? Succeeded: 3

??????????????? Not implemented: 0

??????????????? Failed: 0

??????? Stats by Operator type:

??????????????? Not implemented(0):

??????????????? Failed:

Failed Test Cases:

?

### Run with ACL backend with CPU NEON

$ onnx_test_runner -j 1 -c 1 -r 1 -e acl ./mobilenetv2-7/

…[E:onnxruntime:Default, runner.cc:217 operator()] Test mobilenetv2-7 finished in 0.606 seconds, t

result:

??????? Models: 1

??????? Total test cases: 3

??????????????? Succeeded: 3

??????????????? Not implemented: 0

??????????????? Failed: 0

??????? Stats by Operator type:

??????????????? Not implemented(0):

??????????????? Failed:

Failed Test Cases:

?

### Run with GPU/NPU backend

$ onnx_test_runner -j 1 -c 1 -r 1 -e vsi_npu ./mobilenetv2-7/

…[E:onnxruntime:Default, runner.cc:217 operator()] Test mobilenetv2-7 finished in 0.446 seconds, t

result:

??????? Models: 1

??????? Total test cases: 3

??????????????? Succeeded: 3

??????????????? Not implemented: 0

??????????????? Failed: 0

??????? Stats by Operator type:

??????????????? Not implemented(0):

??????????????? Failed:

Failed Test Cases:

-------------------------------

?

c).?更多示例測試和參數說明以及C++ API可以參考NXP i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0 Chapter 6 ONNX Runtime。

?

?

8). OpenCV?測試

a). OpenCV是大家熟知的一款開源的傳統機器視覺庫,它包含一個ML模塊可以提供傳統的機器學習算法,可以支持神經網絡推理(DNN模型)和傳統機器學習算法(ML模型),NXP iMX8 eIQ OpenCV支持特性如下

./ OpenCV 4.4.0

./ C++ and Python API (supported Python version 3)

./ Only CPU computation is supported

./ Input image or live camera (webcam) is supported

?

b).?示例應用測試

./ BSP?預裝?OpenCV測試模型數據如下

DNN示例應用?- /usr/share/OpenCV/samples/bin

輸入數據、模型配置文件?- /usr/share/opencv4/testdata/dnn

?

./?Image classification DNN示例應用測試

-------------------------------

###?從這里下載,模型文件squeezenet_v1.1.caffemodel和配置文件model.yml復制到?/usr/share/OpenCV/samples/bin

###?復制數據文件到執行目錄

$ cp /usr/share/opencv4/testdata/dnn/dog416.png /usr/share/OpenCV/samples/bin/

$ cp /usr/share/opencv4/testdata/dnn/squeezenet_v1.1.prototxt?/usr/share/OpenCV/samples/bin/

$ cp /usr/share/OpenCV/samples/data/dnn/classification_classes_ILSVRC2012.txt /usr/share/OpenCV/samples/bin/

?

$ cd /usr/share/OpenCV/samples/bin/

### Run with default image

$ ./example_dnn_classification --input=dog416.png --zoo=models.yml squeezenet

?

### Run with actual camera(/dev/video2) input

./example_dnn_classification --device=2 --zoo=models.yml squeezenet

-------------------------------

?

c).?更多示例測試和說明可以參考NXP i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0 Chapter 8 OpenCV machine learning demos。

?

?

9).?總結

本文基于NXP eIQ?機器學習工具庫在iMX8嵌入式平臺簡單演示了多種機器學習推理引擎示例應用,并簡單對比了CPU NEON和GPU進行模型推理的性能表現,實際進行相關應用開發的時候還會遇到很多學習模型到實際推理模型轉換的問題,本文就不做涉及。

?

參考文獻

i.MX Machine Learning User's Guide Rev. L5.4.70_2.3.0

i.MX Yocto Project User's Guide Rev. L5.4.70_2.3.0

https://developer.toradex.cn/knowledge-base/board-support-package/openembedded-core

?

總結

以上是生活随笔為你收集整理的NXP iMX8基于eIQ框架测试Machine Learning的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。