ultralytics的pytorch版本的yolov5项目的yolov5s.pt--onnx--paddle,在onnx2paddle时出现Inferred shape and existing shape differ in dimension 2: (416) vs (208)的错误
Created by: Alex-1997-Wzx
我的模型源文件是yolov5s.pt,使用的是github上的pytorch版本的yolov5的项目,链接附上:https://github.com/ultralytics/yolov5
我在进行pytorch转onnx的时候,是没有问题的,onnx使用的1.6.0,opset版本是11,最终成功生成onnx。使用的转换程序,是该项目提供的export.py,在models文件夹下。
但是在我使用x2paddle转换onnx 的时候,出现了错误,我的paddle版本是1.8,采用github上推荐的第一种方式安装的x2paddle。报错如下:初步看,好像是和shape相关的错误,我设置的模型输入是13416416,但是我不明白错误中提到的208是什么意思。而且当我在将pytorch转换成onnx的时候,如果将输入尺寸设置成13640640,那么错误中就会出现320,都刚好是416或者640的1/2。
希望各位帮我看一下这个应该怎么解决,谢谢啦!!!!!
E:\Python37\Scripts>x2paddle --framework=onnx --model=C:\Users\Alex\Desktop\ultralytics_yolov5_pytorch\models\yolov5s.onnx --save_dir=C:\Users\Alex\Desktop\ultralytics_yolov5_pytorch\models\ --onnx_opset=11 paddle.version = 1.8.3 Now translating model from onnx to paddle. model ir_version: 6, op version: 11 shape inferencing ... Stopping at incomplete shape inference (op_type:Slice, name:x2paddle_171): Inferred shape and existing shape differ in dimension 2: (416) vs (208) Traceback (most recent call last): File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_shape_inference.py", line 1585, in infer_shapes in_mp) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_shape_inference.py", line 1418, in infer_impl self.dispatchernode.op_type File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_shape_inference.py", line 1130, in _infer_Resize assert len(roi) == 2 * rank AssertionError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "E:\Python37\Scripts\x2paddle-script.py", line 33, in sys.exit(load_entry_point('x2paddle==0.8.1', 'console_scripts', 'x2paddle')()) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\convert.py", line 269, in main onnx2paddle(args.model, args.save_dir, params_merge) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\convert.py", line 184, in onnx2paddle model = ONNXDecoder(model_path) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_decoder.py", line 367, in init self.graph = ONNXGraph(onnx_model) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_decoder.py", line 143, in init onnx_model, fixed_input_shape=self.fixed_input_shape) File "E:\Python37\lib\site-packages\x2paddle-0.8.1-py3.7.egg\x2paddle\decoder\onnx_shape_inference.py", line 1595, in infer_shapes symbolic_shape_inference.out_mp_) File "E:\Python37\lib\site-packages\onnx\shape_inference.py", line 35, in infer_shapes inferred_model_str = C.infer_shapes(model_str) RuntimeError: Inferred shape and existing shape differ in dimension 2: (416) vs (208)