PaddlePaddle / X2Paddle

Deep learning model converter for PaddlePaddle. (『飞桨』深度学习模型转换工具)
http://www.paddlepaddle.org/
Apache License 2.0
731 stars 164 forks source link

onnx模型转paddle模型报错 #559

Open yjhtc007 opened 3 years ago

yjhtc007 commented 3 years ago

模型来源: Onnx 模型说明: Faster RCNN检测模型 转换过程出错提示如下:

yjh@yjh-RESCUER-Y720-15IKB:~$ x2paddle --framework=onnx --model=/home/yjh/Pig_CrowdDet-master_debug_mv3_convert_onnx/crowd_mv3_0505_5.onnx --save_dir=pd_model --paddle_type dygraph
paddle.__version__ = 2.0.0
Now translating model from onnx to paddle.
model ir_version: 6, op version: 11
shape inferencing ...
/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle/decoder/onnx_shape_inference.py:510: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  new_v = int(np.asscalar(v))
/home/yjh/anaconda3/lib/python3.6/site-packages/sympy/core/sympify.py:266: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead
  return func(np.asscalar(a))
shape inferenced.
Now, onnx2paddle support convert onnx model opset_verison [9],opset_verison of your onnx model is 11, automatically treated as op_set: 9.

========= 1 OPs are not supported yet ===========
========== NonMaxSuppression ============
Traceback (most recent call last):
  File "/home/yjh/anaconda3/bin/x2paddle", line 8, in <module>
    sys.exit(main())
  File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle/convert.py", line 258, in main
    onnx2paddle(args.model, args.save_dir, args.paddle_type)
  File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle/convert.py", line 167, in onnx2paddle
    mapper = ONNXOpMapper(model)
  File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle/op_mapper/dygraph/onnx2paddle/onnx_op_mapper.py", line 32, in __init__
    raise Exception("Model is not supported yet.")
Exception: Model is not supported yet.

请问现在ONNX转paddle的时候, NonMaxSuppression 还不支持吗?

wjj19950828 commented 3 years ago

麻烦提供一下ONNX模型吧,谢谢啦!

yjhtc007 commented 3 years ago

麻烦提供一下ONNX模型吧,谢谢啦! 您好,关于这个问题我参照了 https://github.com/PaddlePaddle/X2Paddle/pull/486, 似乎已经得到了解决。但是目前我遇到了一个新的问题,如下所示: yjh@yjh-RESCUER-Y720-15IKB:~$ x2paddle --framework=onnx --model=/home/yjh/Pig_CrowdDet-master_debug_mv3_convert_onnx/crowd_mv3_0506_2.onnx --save_dir=pd_model --paddle_type dygraph paddle.version = 2.0.0 Now translating model from onnx to paddle. model ir_version: 6, op version: 11 shape inferencing ... /home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/decoder/onnx_shape_inference.py:510: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead /home/yjh/anaconda3/lib/python3.6/site-packages/sympy/core/sympify.py:266: DeprecationWarning: np.asscalar(a) is deprecated since NumPy v1.16, use a.item() instead return func(np.asscalar(a)) shape inferenced. Now, onnx2paddle support convert onnx model opset_verison [9],opset_verison of your onnx model is 11, automatically treated as op_set: 9. Total nodes: 990 Nodes converting ... Converting node 1693 ...
Nodes converted. Exporting inference model from python code ('/home/yjh/pd_model/x2paddle_code.py')...

W0506 10:55:14.374835 4574 device_context.cc:362] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 10.2, Runtime API Version: 10.2 W0506 10:55:15.117242 4574 device_context.cc:372] device: 0, cuDNN Version: 7.6. Fail to generate inference model! Problem happend while export inference model from python code '/home/yjh/pd_model/x2paddle_code.py';

===================Error Information=============== Traceback (most recent call last): File "/home/yjh/anaconda3/bin/x2paddle", line 33, in sys.exit(load_entry_point('x2paddle==1.1.0', 'console_scripts', 'x2paddle')()) File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/convert.py", line 258, in main File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/convert.py", line 169, in onnx2paddle File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/core/program.py", line 248, in gen_model File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/core/program.py", line 311, in gen_dygraph_model File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/core/program.py", line 307, in gen_dygraph_model File "/home/yjh/anaconda3/lib/python3.6/site-packages/x2paddle-1.1.0-py3.6.egg/x2paddle/core/program.py", line 682, in dygraph2static File "", line 2, in save File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(*args, kwargs) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/base.py", line 39, in impl return func(*args, kwargs) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/jit.py", line 681, in save inner_input_spec) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 488, in concrete_program_specify_input_spec desired_input_spec) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 402, in get_concrete_program concrete_program, partial_program_layer = self._program_cache[cache_key] File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 711, in getitem self._caches[item] = self._build_once(item) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 702, in _build_once class_instance=cache_key.class_instance) File "", line 2, in from_func_spec File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in impl return wrapped_func(args, kwargs) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/base.py", line 39, in impl return func(*args, kwargs) File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 658, in from_func_spec error_data.raise_new_exception() File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/dygraph/dygraph_to_static/error.py", line 189, in raise_newexception six.exec("raise new_exception from None") File "", line 1, in MemoryError: In transformed code:

File "pd_model/x2paddle_code.py", line 1099, in forward (* user code *)
x2paddle_1038_ones = paddle.full(shape=x2paddle_1037, dtype='int64', fill_value=1)
File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/tensor/creation.py", line 484, in full
return fill_constant(shape=shape, dtype=dtype, value=fill_value, name=name)
File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/layers/tensor.py", line 730, in fill_constant
stop_gradient=True)
File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 3018, in append_op
attrs=kwargs.get("attrs", None))
File "/home/yjh/anaconda3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 2217, in __init__
self.desc.infer_shape(self.block.desc)
MemoryError: std::bad_alloc

请问您那边能方便帮我查看一下吗?这是我模型的链接: 链接: https://pan.baidu.com/s/1r3ZEjg4A17EGeB0aetX6WA 密码: uswq 麻烦您了!

wjj19950828 commented 3 years ago

您好,请提供一下之前pytorch模型和几张测试图片吧,这边需要对齐一下精度

yjhtc007 commented 3 years ago

您好,请提供一下之前pytorch模型和几张测试图片吧,这边需要对齐一下精度

您好,不好意思前段时间有点忙,忘记回复您了。我想确认一下需要发给您pytorch的pth模型、推理代码和测试图片对吗?您那边方便提供邮箱吗?

wjj19950828 commented 3 years ago

这边新增了NMS,请重装一下X2Paddle

然后输出下列命令

pip uninstall x2paddle
git clone https://github.com/PaddlePaddle/X2Paddle.git
cd X2Paddle
python setup.py install