The model quantization method is exactly the same as that used by Ultralytics.
We have modified the original code of export model to adapt it for model inference with the Tofu6 module.
The model input is at a resolution of 3x640x640, model type is yolov8s, supports detection models with up to 4 classes.
You can modify the export_nnie.py
file to export your own model.
from ultralytics import YOLO
model = YOLO("./model/yolov8s.pt")
success = model.export(format="onnx", opset=13)
Please note that the code we referenced uses
ONNX opset version 13
.
When using it,please isolate the environment with Anaconda from the training environment,and do not install Ultralytics in the environment to avoid calling the wrong functions for export.
After model quantization,please use Netron
to view the ONNX network.
The correct network should end as shown in the figure below.
This function is based on the Tofu6 VMware image.
Recommanded VMware version is VMware® Workstation 16 Pro or later version.
Use the administrator account, the default password is 123.
sudo su
123
atc --version
Check the current ATC version.
The printing environment is correct.
Printing the following information indicates that the environment is correct.
Mapper Version 1.0.0.0_B010 (PICO_1.0) 2311021147192e53b(CPU) (INST_2.0.9)
Onnx
file which is transfered from .pt
to .onnx
./home/littro/Model/yolov8/
.txt
image list file..txt
file located in /home/littro/Model/coco/
Use the administrator account.
sudo su
123
Run the code after modifying the content.
🟢 Reference command:
atc --dump_data=0 --input_shape="images:1,3,640,640" \
--input_type="images:UINT8" --log_level=0 --online_model_type=0 --batch_num=1 \
--input_format=NCHW \
--output="/root/modelzoo/yolov8s_output/SS928V100/yolov8s_output" \
--soc_version=SS928V100 \
--insert_op_conf=/root/modelzoo/yolov8s/SS928V100/insert_op.cfg \
--framework=5 --compile_mode=0 --save_original_model=false \
--model="/home/littro/Model/yolov8/yolov8s.onnx" \
--image_list="images:/home/littro/Model/coco/imagelist_20240611134217.txt"
Sections that need to be modified manually:
🟢 output: The output path.
The refence in the code is:
--output="/root/modelzoo/yolov8s_output/SS928V100/yolov8s_output"
🟢 model: The path and name of the ONNX model.
The refence in the code is:
--model="/home/littro/Model/yolov8/yolov8s.onnx"
🟢 image_list: A list of image files used as references for model generation.
It should include 20 to 50 images from the training dataset.
The refence in the code is:
--image_list="images:/home/littro/Model/coco/imagelist_20240611134217.txt"
The image list is saved as a.txt
file,with the format as follows:
/home/littro/Model/coco/000000000036.jpg
/home/littro/Model/coco/000000000049.jpg
/home/littro/Model/coco/000000000061.jpg
/home/littro/Model/coco/000000000074.jpg
/home/littro/Model/coco/000000000077.jpg
/home/littro/Model/coco/000000000086.jpg
/home/littro/Model/coco/000000000109.jpg
/home/littro/Model/coco/000000000110.jpg
We provided the reference images and .txt
file located in /home/littro/Model/coco/
.
The model export process will take several minutes.
Once the export is successful,the resulting file will be in the .om
format.
Run the packaging script.
Script path:/home/littro/Model/yolov8/
./encryptmodel yolov8s_output.om model_custom.ir
After running, the packaged model file named model_custom.ir
will be obtained.
Script path:/home/littro/Model/updpkg_custom_script
Copy the generated model_custom.ir
model to the specified path and run the script.
Please note that the model was generated by an administrator.If you copy the file using a regular user,please use the command
chmod 777 file_name
to grant other users permission to edit the file.
./updpkg_custom_model_vis.sh ./model_custom.ir
After running,the .dev
upgrade package will be generated automatically.
This upgrade package can be used for remote upgrades on Tofu6.
For detailed upgrade procedures[click here] ,please refer to the TVMS software user manual.