Paddle2ONNX icon indicating copy to clipboard operation
Paddle2ONNX copied to clipboard

ppmatting 模型导出为onnx时报pool2d不支持export?

Open mmxuan18 opened this issue 3 years ago • 7 comments

请将下面信息填写完整,便于我们快速解决问题,谢谢!

问题描述 使用下面命令转ppmatting的模型为 onnx时报错 paddle2onnx --model_dir . --model_filename model.pdmodel --params_filename model.pdiparams --save_file model.onnx --enable_dev_version True --opset_version 15 [ERROR][Paddle2ONNX][pool2d: pool2d_1.tmp_0] Adaptive only support static input shape. [Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX. [ERROR][Paddle2ONNX][pool2d: pool2d_2.tmp_0] Adaptive only support static input shape. [Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX.

模型为https://paddleseg.bj.bcebos.com/matting/models/deploy/pp-matting-hrnet_w18-human_1024.zip

更多信息 :

  • 用于部署的推理引擎: onnxruntime
  • 为什么需要转换为ONNX格式:能使用现有的服务
  • Paddle2ONNX版本: paddle-bfloat 0.1.7 paddle2onnx 0.9.8 paddlepaddle 2.3.1 paddleseg 2.6.0
  • 你的联系方式(Email/Wechat/Phone): [email protected] 报错截图

其他信息

mmxuan18 avatar Jul 21 '22 11:07 mmxuan18

[ERROR][Paddle2ONNX][pool2d: pool2d_2.tmp_0] Adaptive only support static input shape. 根据这里的提示,你这里的pool2d是一个AdaptivePooling , 而ONNX无此对应OP,因此需要固定原模型的输入shape, 在部分情况下,可以将AdaptivePooling转为普通Pool2d进行导出

jiangjiajun avatar Jul 22 '22 02:07 jiangjiajun

[ERROR][Paddle2ONNX][pool2d: pool2d_2.tmp_0] Adaptive only support static input shape. 根据这里的提示,你这里的pool2d是一个AdaptivePooling , 而ONNX无此对应OP,因此需要固定原模型的输入shape, 在部分情况下,可以将AdaptivePooling转为普通Pool2d进行导出

同问,怎么“固定原模型的输入shape”? 我用下面操作进行固化:python paddle_infer_shape.py --model_dir D:/CV/dataset/HumanSeg/inference_models/humansegmodel2 --model_filename model.pdmodel --params_filename model.pdiparams --save_dir D:/CV/dataset/HumanSeg/inference_models/staticinput --input_shape_dict="{'x':[-1,3,192,192]}" 但是并没有输出固化后的模型,也没有报错,只输出了一句话: Start to load paddle model...

LuWei6896 avatar Mar 20 '23 05:03 LuWei6896

@jiangjiajun I am also confused a lot.....

paddle2onnx --model_dir .\human_pp_humansegv2_lite_192x192_inference_model\ --model_filename model.pdmodel --params_filename model.pdiparams --save_file ppsegv2_lite_192x192.onnx --opset_version 11 --input_shape_dict "{'image':[1, 3, 192, 192]}"
2023-04-08 16:05:56 [WARNING]   [Deprecated] The flag `--input_shape_dict` is deprecated, if you need to modify the input shape of PaddlePaddle model, please refer to this tool https://github.com/jiangjiajun/PaddleUtils/tree/main/paddle
[Paddle2ONNX] Start to parse PaddlePaddle model...
[Paddle2ONNX] Model file path: .\human_pp_humansegv2_lite_192x192_inference_model\model.pdmodel
[Paddle2ONNX] Paramters file path: .\human_pp_humansegv2_lite_192x192_inference_model\model.pdiparams
[Paddle2ONNX] Start to parsing Paddle model...
[ERROR][Paddle2ONNX] [pool2d: pool2d_9.tmp_0] Adaptive only support static input shape.
[Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX.
[ERROR][Paddle2ONNX] [pool2d: pool2d_10.tmp_0] Adaptive only support static input shape.
[Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX.
[ERROR] Model exporting failed, you can report this problem to https://github.com/PaddlePaddle/Paddle2ONNX.git.

lucasjinreal avatar Apr 08 '23 08:04 lucasjinreal

原因是在调用export.py时没有固定shape。因为pp-matting-hrnet_w18-human_1024的配置文件没有指定固定的输入shape。再调用export.py时,添加参数--input_shape。例子如下: python tools/export.py \ --config configs/pp_liteseg/pp_liteseg_stdc1_cityscapes_1024x512_scale0.5_160k.yml \ --model_path model.pdparams \ --save_dir output/inference_model \ --input_shape 1 3 1024 1024 导出后,再调用paddle2onnx方法转换模型。

tianji2018 avatar Apr 11 '23 08:04 tianji2018

嗯 我已经解决了,感谢--发自新浪邮箱客户端 在 4月11日 16:06,tianji2018 @.***> 写道:

原因是在调用export.py时没有固定shape。因为pp-matting-hrnet_w18-human_1024的配置文件没有指定固定的输入shape。再调用export.py时,添加参数--input_shape。例子如下:

python tools/export.py \ --config configs/pp_liteseg/pp_liteseg_stdc1_cityscapes_1024x512_scale0.5_160k.yml \ --model_path model.pdparams \ --save_dir output/inference_model \ --input_shape 1 3 1024 1024

导出后,再调用paddle2onnx方法转换模型。

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

LuWei6896 avatar Apr 11 '23 08:04 LuWei6896

@jiangjiajun 这个地方我也有个问题, 为什么前段时间还能成功转但是最近就报错了。https://bj.bcebos.com/paddlehub/fastdeploy/Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer.tgz 这个模型近期是有调整吗?上周还能成功转onnx但是今天再去测试就报错了。 `2024-01-05 05:09:04 (221 KB/s) - ‘Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer.tgz’ saved [3563030/3563030]

./Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer/ ./Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer/model.pdiparams.info ./Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer/model.pdiparams ./Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer/deploy.yaml ./Portrait_PP_HumanSegV2_Lite_256x144_with_argmax_infer/model.pdmodel Traceback (most recent call last): File "paddle_infer_shape.py", line 82, in import paddle.fluid as fluid ModuleNotFoundError: No module named 'paddle.fluid' [Paddle2ONNX] Start to parse PaddlePaddle model... [Paddle2ONNX] Model file path: /home/ubuntu/Paddle-examples-for-AVH/object_segmentation/model/model.pdmodel [Paddle2ONNX] Paramters file path: /home/ubuntu/Paddle-examples-for-AVH/object_segmentation/model/model.pdiparams [Paddle2ONNX] Start to parsing Paddle model... [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_0.tmp_0] Requires the minimal opset version of 11. [ERROR][Paddle2ONNX] [pool2d: pool2d_9.tmp_0] Adaptive only support static input shape. [Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_1.tmp_0] Requires the minimal opset version of 11. [ERROR][Paddle2ONNX] [pool2d: pool2d_10.tmp_0] Adaptive only support static input shape. [Paddle2ONNX] Due to the operator: pool2d, this model cannot be exported to ONNX. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_2.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_3.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_4.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_5.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_6.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_7.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] [bilinear_interp_v2: bilinear_interp_v2_8.tmp_0] Requires the minimal opset version of 11. [Paddle2ONNX] Due to the operator: bilinear_interp_v2, requires opset_version >= 11. [ERROR] Model exporting failed, you can report this problem to https://github.com/PaddlePaddle/Paddle2ONNX.git.`

Liliyaw avatar Jan 05 '24 05:01 Liliyaw

如果调用export.py时,我不想指定input_size,使用paddle2onnx转换时该怎么处理报错的问题

wangkd0 avatar Apr 19 '24 08:04 wangkd0