跳到主要内容

MobileNetV2 Int8

MobileNet 是由 Google 专门为移动端和嵌入式设备设计的轻量级深度神经网络系列。它通过革新卷积计算方式,大幅降低了模型的参数量与计算复杂度,使得高性能视觉算法能够在智能手机、物联网终端等算力受限的设备上实时运行。

  • 核心特点:支持高效的图像分类、目标检测及语义分割,通过极低的延迟实现高质量的视觉感知,是移动端深度学习应用的核心引擎。
  • 版本说明:本案例采用的是 MobileNetV2 Int8 版本。作为轻量级网络的代表,它在计算效率与识别准确率之间实现了优异平衡,非常适合移动端及边缘设备的实时视觉任务部署。
环境配置

需要提前配置好相关环境。

快速开始

下载模型文件

O6 / O6N
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model
wget -O mobilenetv2-12-int8-fix.onnx https://modelscope.cn/models/cix/ai_model_hub_25_Q3/resolve/master/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model/mobilenetv2-12-int8-fix.onnx

模型测试

信息

运行前激活虚拟环境!

O6 / O6N
python3 inference_onnx.py --EP NPU

完整转换流程

下载模型文件

Linux PC
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model
wget -O mobilenetv2-12-int8.onnx https://modelscope.cn/models/cix/ai_model_hub_25_Q3/resolve/master/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model/mobilenetv2-12-int8.onnx

项目结构

├── inference_onnx.py
├── model
├── ReadMe.md
└── test_data

固定模型输入形状

Linux PC
python3 -m onnxruntime.tools.make_dynamic_shape_fixed --dim_param batch_size --dim_value 1 mobilenetv2-12-int8.onnx mobilenetv2-12-int8-fix.onnx
推送到板端

完成模型转换之后需要将 cix 模型文件推送到板端。

测试主机推理

Linux PC
python3 inference_onnx.py --EP CPU

进行 NPU 部署

导出环境变量

O6 / O6N
export LD_LIBRARY_PATH=/usr/share/cix/lib/onnxruntime:$LD_LIBRARY_PATH
export OPERATOR_PATH=/usr/share/cix/lib/onnxruntime/operator/

运行推理脚本

O6 / O6N
python3 inference_onnx.py --EP NPU

模型推理结果

O6 / O6N
$ python3 ./inference_onnx.py --EP npu
image path : ./test_data/ILSVRC2012_val_00037133.JPEG
ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
image path : ./test_data/ILSVRC2012_val_00021564.JPEG
coucal
image path : ./test_data/ILSVRC2012_val_00024154.JPEG
Ibizan hound, Ibizan Podenco
image path : ./test_data/ILSVRC2012_val_00002899.JPEG
rock python, rock snake, Python sebae
image path : ./test_data/ILSVRC2012_val_00045790.JPEG
Yorkshire terrier

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

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