PaddlePaddle / Paddle2ONNX

ONNX Model Exporter for PaddlePaddle
Apache License 2.0
670 stars 157 forks source link

module 'paddle.fluid.layers' has no attribute 'pad2d' #1162

Closed zr-icu closed 4 months ago

zr-icu commented 7 months ago

转db++模型到onnx的时候,使用命令

paddle2onnx --model_dir ./inference/det_db++/ --model_filename inference.pdmodel --params_filename inference.pdiparams --save_file ./inference/det_db++/model.onnx --opset_version 11 --input_shape_dict="{'x':[-1,3,-1,-1]}" --enable_onnx_checker True --enable_dev_version False

版本: paddlepaddle== 2.5.1 onnx == 1.10.0 paddle2onnx == 1.0.2

报错: Traceback (most recent call last): File "/opt/conda/bin/paddle2onnx", line 8, in sys.exit(main()) File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/command.py", line 250, in main program2onnx( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/command.py", line 168, in program2onnx return program2onnx(model_dir, save_file, model_filename, params_filename, File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/command.py", line 200, in program2onnx p2o.program2onnx( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/convert.py", line 78, in program2onnx return program2onnx(program, scope, save_file, feed_var_names, target_vars, File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/convert.py", line 95, in program2onnx return export_onnx( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/convert.py", line 35, in export_onnx onnx_graph = ONNXGraph.build(paddle_graph, opset_version, File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/graph/onnx_graph.py", line 323, in build onnx_graph = ONNXGraph( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/graph/onnx_graph.py", line 85, in init self.update_opset_version() File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/graph/onnx_graph.py", line 202, in update_opset_version self.opset_version = OpMapper.get_recommend_opset_version( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/op_mapper/op_mapper.py", line 147, in get_recommend_opset_version custom_paddle_graph, output_results = custom_paddle_op.get_paddle_graph( File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/op_mapper/op_mapper.py", line 262, in get_paddle_graph res = self.forward() File "/opt/conda/lib/python3.8/site-packages/paddle2onnx/legacy/op_mapper/custom_paddle_op/deformable_conv.py", line 66, in forward input = layers.pad2d(input, self.padding) AttributeError: module 'paddle.fluid.layers' has no attribute 'pad2d'

jiangjiajun commented 7 months ago

安装低于2.4版本的Paddle

HawkingRadiation42 commented 5 months ago

@zr-icu were you able to solve this issue?

zr-icu commented 5 months ago

@zr-icu were you able to solve this issue?

yes, I downgraded the version paddlepaddle to 2.4.2 and the problem was solved.

HawkingRadiation42 commented 5 months ago

thankyou worked for me as well but generated a bunch of warnings.

C:\Users\admin\anaconda3\envs\onnx\lib\site-packages\paddle\fluid\layers\math_op_patch.py:410: DeprecationWarning: C:\Users\admin\anaconda3\envs\onnx\lib\site-packages\paddle2onnx\legacy\op_mapper\custom_paddle_op\deformable_conv.py:127 The behavior of expression A * B has been unified with elementwise_mul(X, Y, axis=-1) from Paddle 2.0. If your code works well in the older versions but crashes in this version, try to use elementwise_mul(X, Y, axis=0) instead of A * B. This transitional warning will be dropped in the future. warnings.warn( C:\Users\admin\anaconda3\envs\onnx\lib\site-packages\onnx\helper.py:363: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working is_iterable = isinstance(value, collections.Iterable)