跳到主要内容

ResNet50

开始之前,请先完成环境配置:

Host 端模型转换

快速体验

如果只需在设备端快速运行模型,可以跳过 Host 端转换,直接使用预编译 DLA 模型

克隆项目

Host PC
git clone https://github.com/Ronin-1124/nio12l-model-zoo.git
cd nio12l-model-zoo

下载模型

提示

如果还没有安装项目依赖,请先在项目根目录运行:

pip install -r requirements.txt

Host PC
cd examples/resnet50/convert_model
conda activate np8
python download_model.py

准备校准数据

Host PC
cd ../../..
python prepare_calibration_data.py path=./datasets/imagenet100 imgsz=224

转换模型

Host PC
cd examples/resnet50/convert_model
python convert_mtk_fp32.py
python convert_mtk_int8.py

转换完成后,在 examples/resnet50/model/ 目录下生成:

  • int8/resnet50_mtk_int8.tflite
  • fp32/resnet50_mtk_fp32.tflite

Device 端部署

克隆项目

Device
git clone https://github.com/Ronin-1124/nio12l-model-zoo.git
cd nio12l-model-zoo

获取模型

方式一:下载预编译 DLA(推荐)

Device
wget -P examples/resnet50/model/int8 https://github.com/Ronin-1124/nio12l-model-zoo/releases/download/v2026.05.11-dla/resnet50_int8.dla
wget -P examples/resnet50/model/fp32 https://github.com/Ronin-1124/nio12l-model-zoo/releases/download/v2026.05.11-dla/resnet50_fp32.dla

方式二:从 Host 端转换

传输模型
Host PC
scp resnet50_mtk_int8.tflite <user>@<device>:/path/to/nio12l-model-zoo/examples/resnet50/model/int8/
scp resnet50_mtk_fp32.tflite <user>@<device>:/path/to/nio12l-model-zoo/examples/resnet50/model/fp32/
转换为 DLA
Device
cd examples/resnet50/model/int8
ncc-tflite --arch=mdla2.0 -d resnet50_int8.dla resnet50_mtk_int8.tflite
cd ../fp32
ncc-tflite --arch=mdla2.0 -d resnet50_fp32.dla resnet50_mtk_fp32.tflite --relax-fp32

编译

Device
cd /path/to/nio12l-model-zoo
cmake -S . -B build
cmake --build build -j

运行

默认使用 INT8 模型:

Device
./build/resnet50_demo

使用 FP32 模型:

Device
./build/resnet50_demo --fp32

性能参考(1000 次推理取平均耗时):

精度耗时 (ms)帧率 (FPS)
INT819.99050.03
FP3244.14222.65

结果保存在 outputs/resnet50/classifications/

    您需要登录 GitHub 才能发表评论。如果您已登录,请忽略此消息。

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0