ResNet50
ResNet is a milestone deep convolutional neural network architecture proposed by Microsoft Research. It perfectly solves the gradient vanishing problem in deep networks through its pioneering residual learning mechanism using "skip connections," completely breaking the limitations on model depth in deep learning.
- Key Features: Focuses on high-precision image feature extraction and classification tasks. Its powerful universal feature representation capabilities make it the most commonly used backbone architecture for complex vision tasks such as object detection and semantic segmentation.
- Version Note: This case uses ResNet-50 (V1). As the most representative mid-range force in the ResNet family, it consists of a 50-layer deep network and adopts an efficient bottleneck structure. It achieves perfect balance between computational complexity and recognition accuracy, making it the most widely deployed classic vision model in industry with both high performance and high stability.
Environment Setup
Configure the required environment in advance.
Quick Start
Download Model Files
O6 / O6N
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_resnet_v1_50
wget https://www.modelscope.cn/models/cix/ai_model_hub_25_Q3/resolve/master/models/ComputeVision/Image_Classification/onnx_resnet_v1_50/resnet_v1_50.cix
Model Testing
info
Activate the virtual environment before running!
O6 / O6N
python3 inference_npu.py
Complete Conversion Workflow
Download Model Files
Linux PC
cd ai_model_hub_25_Q3/models/ComputeVision/Image_Classification/onnx_resnet_v1_50/model
wget https://www.modelscope.cn/models/cix/ai_model_hub_25_Q3/resolve/master/models/ComputeVision/Image_Classification/onnx_resnet_v1_50/model/resnet50-v1-12.onnx
wget https://www.modelscope.cn/models/cix/ai_model_hub_25_Q3/resolve/master/models/ComputeVision/Image_Classification/onnx_resnet_v1_50/model/resnet50-v1-12-sim.onnx
Project Structure
├── cfg
├── datasets
├── inference_npu.py
├── inference_onnx.py
├── model
├── ReadMe.md
├── resnet_v1_50.cix
├── test_data
├── label.txt
├── main.cpp
├── makefile
├── noe_utils
└── Tutorials.ipynb
Perform Model Quantization and Conversion
Linux PC
cd ..
cixbuild cfg/onnx_resnet_v1_50build.cfg
Push to Board
After completing the model conversion, push the cix model file to the board.
Test Host Inference
Run Inference Script
Linux PC
python3 inference_onnx.py --images test_data --onnx_path model/resnet50-v1-12-sim.onnx
Model Inference Results
Linux PC
$ python3 inference_onnx.py --images test_data --onnx_path model/resnet50-v1-12-sim.onnx
image path : test_data/ILSVRC2012_val_00024154.JPEG
Ibizan hound, Ibizan Podenco
image path : test_data/ILSVRC2012_val_00021564.JPEG
coucal
image path : test_data/ILSVRC2012_val_00002899.JPEG
rock python, rock snake, Python sebae
image path : test_data/ILSVRC2012_val_00045790.JPEG
Yorkshire terrier
image path : test_data/ILSVRC2012_val_00037133.JPEG
ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
Deploy to NPU
Run Inference Script
O6 / O6N
python3 inference_npu.py --images test_data --model_path resnet_v1_50.cix
Model Inference Results
O6 / O6N
$ python3 inference_npu.py --images test_data --model_path resnet_v1_50.cix
npu: noe_init_context success
npu: noe_load_graph success
Input tensor count is 1.
Output tensor count is 1.
npu: noe_create_job success
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
npu: noe_clean_job success
npu: noe_unload_graph success
npu: noe_deinit_context success