MobileNetV2 Int8
MobileNet is a lightweight deep neural network family designed by Google for mobile and embedded devices. By using efficient convolution designs, it significantly reduces parameter count and compute cost, enabling real-time vision workloads on resource-constrained devices such as smartphones and IoT terminals.
- Key features: efficient image classification, object detection, and semantic segmentation with low latency.
- Variant: this guide uses MobileNetV2 Int8, which balances accuracy and efficiency and is well-suited for real-time edge deployments.
Environment setup
Make sure the required environment is ready:
Quick Start
Download the model files
O6 / O6N
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model
wget 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
Test the model
info
Activate your virtual environment before running.
O6 / O6N
python3 inference_onnx.py --EP NPU
Full Conversion Workflow
Download the model files
Linux PC
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_mobilenet_v2_12_int8/model
wget 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
Project structure
├── inference_onnx.py
├── model
├── ReadMe.md
└── test_data
Fix the model input shape
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
Copy to the device
After the conversion, copy the cix model files to the device.
Test inference on the host
Linux PC
python3 inference_onnx.py --EP CPU
Deploy on the NPU
Export environment variables
O6 / O6N
export LD_LIBRARY_PATH=/usr/share/cix/lib/onnxruntime:$LD_LIBRARY_PATH
export OPERATOR_PATH=/usr/share/cix/lib/onnxruntime/operator/
Run the inference script
O6 / O6N
python3 inference_onnx.py --EP NPU
Inference result
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