1将 [classification.py](https://github.com/AXERA-TECH/pyaxengine/blob/main/examples/classification.py) 拷贝到开发板上并执行。
2
3```bash
4root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg
5[INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
6[INFO] Using provider: AxEngineExecutionProvider
7[INFO] Chip type: ChipType.MC50
8[INFO] VNPU type: VNPUType.DISABLED
9[INFO] Engine version: 2.10.1s
10[INFO] Model type: 0 (single core)
11[INFO] Compiler version: 1.2-patch2 7e6b2b5f
12 ------------------------------------------------------
13 Top 5 Predictions:
14 Class Index: 282, Score: 9.774
15 Class Index: 278, Score: 8.981
16 Class Index: 277, Score: 8.453
17 Class Index: 281, Score: 8.321
18 Class Index: 287, Score: 7.924
19 ------------------------------------------------------
20 min = 0.890 ms max = 22.417 ms avg = 1.119 ms
21 ------------------------------------------------------
切换计算设备的方式是通过
-p 参数指定,如
-p AxEngineExecutionProvider 表示使用开发板上的 NPU 进行推理,而
-p AXCLRTExecutionProvider 表示使用 M.2 算力卡进行推理。
注意:在使用 M.2 算力卡进行推理时,需要将算力卡插入宿主机上,并且已经安装驱动,详见:
axcl。
1root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg -p AXCLRTExecutionProvider
2[INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
3[INFO] Using provider: AXCLRTExecutionProvider
4[INFO] SOC Name: AX650N
5[INFO] VNPU type: VNPUType.DISABLED
6[INFO] Compiler version: 1.2-patch2 7e6b2b5f
7 ------------------------------------------------------
8 Top 5 Predictions:
9 Class Index: 282, Score: 9.774
10 Class Index: 278, Score: 8.981
11 Class Index: 277, Score: 8.453
12 Class Index: 281, Score: 8.321
13 Class Index: 287, Score: 7.924
14 ------------------------------------------------------
15 min = 1.587 ms max = 12.624 ms avg = 1.718 ms
16 ------------------------------------------------------
17root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg -p AxEngineExecutionProvider
18[INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
19[INFO] Using provider: AxEngineExecutionProvider
20[INFO] Chip type: ChipType.MC50
21[INFO] VNPU type: VNPUType.DISABLED
22[INFO] Engine version: 2.10.1s
23[INFO] Model type: 0 (single core)
24[INFO] Compiler version: 1.2-patch2 7e6b2b5f
25 ------------------------------------------------------
26 Top 5 Predictions:
27 Class Index: 282, Score: 9.774
28 Class Index: 278, Score: 8.981
29 Class Index: 277, Score: 8.453
30 Class Index: 281, Score: 8.321
31 Class Index: 287, Score: 7.924
32 ------------------------------------------------------
33 min = 0.897 ms max = 22.542 ms avg = 1.125 ms
34 ------------------------------------------------------