ResNet50
开始之前,请先完成环境配置:
- Host 模型转换工具 — 安装 NeuroPilot Converter
- Device 环境配置 — 安装 Neuron SDK
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.tflitefp32/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) |
|---|---|---|
| INT8 | 19.990 | 50.03 |
| FP32 | 44.142 | 22.65 |
结果保存在 outputs/resnet50/classifications/。