Closed luoduo21 closed 4 years ago
有尝试过转换未经过onnx-simplifier-master的模型吗?
用onnx=1.6.0一直提示 onnx==1.5.0 is required
所以环境用的pytorch1.3,onnx=1.5.0,onnxruntime=1.0.0,使用未经过onnx-simplifier-master转换的SSD模型,错误如下:
(pytorch1.3) zt@zt:~/androidprojects/X2Paddle-develop$ x2paddle --framework=onnx --model=test.onnx --save_dir=pd_model
Now translating model from onnx to paddle.
model ir_version: 4, op version: 9
onnxruntime==0.4.0 is required
Total nodes: 206
in (Constant -> _107): attribute "shape" of _107 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _111): attribute "shape" of _111 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _160): attribute "shape" of _160 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _163): attribute "shape" of _163 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _168): attribute "shape" of _168 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _171): attribute "shape" of _171 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _176): attribute "shape" of _176 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _179): attribute "shape" of _179 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _184): attribute "shape" of _184 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _187): attribute "shape" of _187 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _192): attribute "shape" of _192 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _195): attribute "shape" of _195 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _200): attribute "shape" of _200 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _203): attribute "shape" of _203 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _209): attribute "shape" of _209 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _212): attribute "shape" of _212 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _217): attribute "shape" of _217 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _220): attribute "shape" of _220 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _225): attribute "shape" of _225 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _228): attribute "shape" of _228 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _233): attribute "shape" of _233 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _236): attribute "shape" of _236 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _241): attribute "shape" of _241 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _244): attribute "shape" of _244 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _249): attribute "shape" of _249 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _252): attribute "shape" of _252 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _258): attribute "shape" of _258 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _261): attribute "shape" of _261 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _262): attribute "shape" of _262 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _268): attribute "shape" of _268 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _271): attribute "shape" of _271 not inferred, using value as 1-D tensor may lead to fails
in (Constant -> _272): attribute "shape" of _272 not inferred, using value as 1-D tensor may lead to fails
Traceback (most recent call last):
File "/home/zt/tools/anaconda3/envs/pytorch1.1/bin/x2paddle", line 11, in
并且torchvision里的model大部分转换都失败,只有直接使用提供的shuffleNet onnx能转换成功.
x2paddle --framework=onnx --model=resnet18.onnx --save_dir=pd_model
Now translating model from onnx to paddle.
model ir_version: 4, op version: 9
onnxruntime==0.4.0 is required
Total nodes: 69
Traceback (most recent call last):
File "/home/zt/tools/anaconda3/envs/pytorch1.1/bin/x2paddle", line 11, in
已解决x2paddle更新到0.7.0就没问题了
Now translating model from onnx to paddle. model ir_version: 4, op version: 9 Total nodes: 98 Traceback (most recent call last): File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/core/op_mapper.py", line 122, in save_inference_model inputs, outputs = model.x2paddle_net() File "pd_model/model_with_code/model.py", line 7, in x2paddle_net _107 = fluid.layers.create_parameter(dtype='float32', shape=[], name='_107', attr='_107', default_initializer=Constant(0.0)) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/layers/tensor.py", line 103, in create_parameter default_initializer) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/layer_helper_base.py", line 330, in create_parameter *attr._to_kwargs(with_initializer=True)) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 2384, in create_parameter param = Parameter(global_block, args, **kwargs) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 4471, in init "The dimensions of shape for Parameter must be greater than 0") ValueError: The dimensions of shape for Parameter must be greater than 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/zt/tools/anaconda3/envs/pytorch1.3/bin/x2paddle", line 11, in
load_entry_point('x2paddle==0.6.0', 'console_scripts', 'x2paddle')()
File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/convert.py", line 233, in main
onnx2paddle(args.model, args.save_dir, params_merge)
File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/convert.py", line 176, in onnx2paddle
mapper.save_inference_model(save_dir, params_merge)
File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/core/op_mapper.py", line 158, in save_inference_model
.format(py_code_dir))
Exception: Paddle code was saved in pd_model/model_with_code/model.py, but seems there's wrong exist, please check model.py manually.
onnx文件先经过onnx-simplifier-master工具转化过,出错的地方为L2Norm部分,不知道是不是因为_107处常量没有scope.
%106 : Float(1, 1024, 19, 19) = onnx::Relu(%105), scope: SSD/VGG16[base]/ReLU # /home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/nn/functional.py:914:0 %107 : Float() = onnx::Constant[value={2}]() %108 : Float(1, 512, 38, 38) = onnx::Pow(%94, %107), scope: SSD/L2Norm[L2Norm] # /home/zt/PycharmProjects/fssd.pytorch-master/models/SSD_vgg.py:268:0