尝试将最新的yolov8模型转换为爱芯派的模型。
首先自己在任意机器上准备好docker环境,详细步骤见官网。
将PyTorch模型格式转为onnx模型格式。yolo mode=export model=yolov8n.pt format=onnx dynamic=False
。
这里需要有yolo的环境,自己安装 pip install ultralytics -i https://pypi.tuna.tsinghua.edu.cn/simple
,有其他需要的依赖包,接着继续安装。
转换完了之后,会生成一个yolov8n.onnx文件。
version=1.9_enc
docker run -it --net host --rm -v **PWD:/data pulsar2:**{version}
如果用docker 环境,可能会遇到以下错误
onnxruntime.capi.onnxruntime_pybind11_state.InvalidArgument: [ONNXRuntimeError] : 2 : INVALID_ARGUMENT : Failed to load model with error: /onnxruntime_src/onnxruntime/core/graph/model_load_utils.h:47 void onnxruntime::model_load_utils::ValidateOpsetForDomain(const std::unordered_map[std::basic_string](), int>&, const onnxruntime::logging::Logger&, bool, const string&, int) ONNX Runtime only *guarantees* support for models stamped with official released onnx opset versions. Opset 17 is under development and support for this is limited. The operator schemas and or other functionality may change before next ONNX release and in this case ONNX Runtime will not guarantee backward compatibility. Current official support for domain ai.onnx is till opset 16.
主要是onnx和onnxruntime版本不对,更新一下就可以了
pip install onnxruntime==1.15 -i https://pypi.tuna.tsinghua.edu.cn/simple
然后再运行 onnxsim yolov8n.onnx yolov8nsim.onnx
准备好config.json文件,然后运行命令。pulsar2 build --input yolov8nsim.onnx --output_dir output --config config.json
, 将会得到output/compiled.axmodel文件。
通过开发板上预制的ax_run_model 工具,测试模型速度和精度。
示例都是yolov5的,没有yolov8,模型怎么运行还需进一步研究。
更多回帖