Paddle2ONNX icon indicating copy to clipboard operation
Paddle2ONNX copied to clipboard

paddleSeg 训练出来的模型onnx转换报错

Open hjm0613 opened this issue 3 years ago • 7 comments

Please fill in the information below so that we can solve the problem quickly, Thanks !

Describe the bug A clear and concise description of what the bug is. 作者您好,我才用paddleSeg -v0.7完成样例模型的训练,运行模型导出函数export_model.py,得到模型和参数文件,静态转换为onnx模型时报错如下: AttributeError: module 'paddle' has no attribute 'float32' 安装的paddle=1.8.5,onnx=1.9。望给以解答,万分感谢。

Informations (please complete the following information):

  • Inference engine for deployment:
  • Why convert to onnx:
  • Paddle2ONNX Version:
  • Email/Wechat/Phone:

Screenshots

Additional context

hjm0613 avatar Jan 20 '22 09:01 hjm0613

请将paddle升级到2.2.0以上版本

另外我们也准备了一份问卷,方便的话请抽出半分钟时间帮完成问卷 https://iwenjuan.baidu.com/?code=r8hu2s 帮助Paddle2ONNX做得更好

jiangjiajun avatar Jan 20 '22 11:01 jiangjiajun

我将paddle版本升级到2.2.1,报了另外一个错误: maybe the loaded file is not a paddle model(expected file format: 0, but 1904018048 found) 请问这是为什么,和我使用paddle=1.8.5训练模型有关不?

hjm0613 avatar Jan 21 '22 01:01 hjm0613

请问paddleSeg语义分割模型是否能转换为onnx模型?

hjm0613 avatar Jan 21 '22 01:01 hjm0613

能够

jiangjiajun avatar Jan 21 '22 02:01 jiangjiajun

我将paddle版本升级到2.2.1,报了另外一个错误: maybe the loaded file is not a paddle model(expected file format: 0, but 1904018048 found) 请问这是为什么,和我使用paddle=1.8.5训练模型有关不?

麻烦贴一下你的转换命令,看起来是命令传参没正确导致

jiangjiajun avatar Jan 21 '22 02:01 jiangjiajun

你好,这是我的转换命令: paddle2onnx --model_dir ./saved_model/deeplabv3p_xception65_bn_optic/final --model_filename model.pdmodel --params_filename model.pdparams --save_file model.onnx --opset_version 10 --enable_onnx_checker True

hjm0613 avatar Jan 21 '22 02:01 hjm0613

上面从文件后辍名来看,是训练过程保存下来的model.pdmodel和model.pdparams,需要先导出为inference格式(即model.pdmodel和model.pdiparams)

先参照这个文档获得inference模型,再导出到onnx https://github.com/PaddlePaddle/PaddleSeg/blob/release/2.4/docs/model_export_cn.md

jiangjiajun avatar Jan 21 '22 02:01 jiangjiajun