Paddle2ONNX
Paddle2ONNX copied to clipboard
paddledetection 训练的faster rcnn模型转换为onnx
请问paddledetection 训练的faster rcnn模型能用paddle2onnx转换为onnx模型吗
可以
可以
谢谢!
可以
可是我在转换faster rcnn r50 fpn训练的模型 遇到了问题, paddlepaddle 版本 2.2.2 paddledetection 2.4
输入命令:
paddle2onnx --model_dir inference_model/faster_rcnn_r50_fpn_1x_coco
--model_filename model.pdmodel
--params_filename model.pdiparams
--save_file model.onnx --enable_onnx_checker True
--enable_dev_version True
报错如下:
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/onnx/mapping.py:27: DeprecationWarning: np.object
is a deprecated alias for the builtin object
. To silence this warning, use object
by itself. Doing this will not modify any behavior and is safe.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
int(TensorProto.STRING): np.dtype(np.object)
[Paddle2ONNX] Start to parse PaddlePaddle model(model file: inference_model/faster_rcnn_r50_fpn_1x_coco/model.pdmodel, parameters file: inference_model/faster_rcnn_r50_fpn_1x_coco/model.pdiparams
[Paddle2ONNX] Model loaded, start to converting...
[Paddle2ONNX] LodTensorArray is not supported.
[Paddle2ONNX] LodTensorArray is not supported.
[Paddle2ONNX] LodTensorArray is not supported.
[Paddle2ONNX] Only support number of inputs equals to number of outputs for operator 'while'.
[Paddle2ONNX] Oops, there are some operators not supported yet, including conditional_block,distribute_fpn_proposals,generate_proposals_v2,lod_array_length,select_input,tensor_array_to_tensor,while,write_to_array,
[ERROR] Due to the unsupported operators, the conversion is aborted.
C++ Traceback (most recent call last):
No stack trace in paddle, may be caused by external reasons.
Error Message Summary:
FatalError: Process abort signal
is detected by the operating system.
[TimeInfo: *** Aborted at 1652668366 (unix time) try "date -d @1652668366" if you are using GNU date ***]
[SignalInfo: *** SIGABRT (@0x3e8000006a1) received by PID 1697 (TID 0x7fa00f210700) from PID 1697 ***]
已放弃 (核心已转储)
- 安装github上paddle2onnx的代码
- 转换时将--enable_dev_version设为False
PaddleDetection在export_model的时候,需在配置文件中添加export_onnx: True
- 安装github上paddle2onnx的代码
- 转换时将--enable_dev_version设为False
PaddleDetection在export_model的时候,需在配置文件中添加export_onnx: True 我按照您的指导,进行了如下操作 1、安装github上paddle2onnx的代码 git clone https://github.com/PaddlePaddle/Paddle2ONNX.git cd Paddle2ONNX python setup.py install 最终安装的paddle2onnx版本为0.9.3
- 转换时将--enable_dev_version设为False
paddle2onnx --model_dir ./
--model_filename model.pdmodel
--params_filename model.pdiparams
--save_file model.onnx --enable_onnx_checker True
--enable_dev_version False --opset_version 16 3、PaddleDetection在export_model的时候,需在配置文件中添加export_onnx: True
最终转换模型时,输出如下:
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/onnx/mapping.py:27: DeprecationWarning: np.object
is a deprecated alias for the builtin object
. To silence this warning, use object
by itself. Doing this will not modify any behavior and is safe.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
int(TensorProto.STRING): np.dtype(np.object)
2022-05-16 11:44:42 [WARNING] [Paddle2ONNX][WARN] This package didn't compile with deploykit, refer https://github.com/PaddlePaddle/Paddle2ONNX/tree/deploykit/docs/zh/deploykit.md for more details.
2022-05-16 11:44:42 [WARNING] [Paddle2ONNX][WARN] This package didn't compile with onnxruntime backend, refer https://github.com/PaddlePaddle/Paddle2ONNX/tree/deploykit/docs/zh/deploykit.md for more details.
2022-05-16 11:44:42 [WARNING] [Paddle2ONNX][WARN] This package didn't compile with TensorRT backend, refer https://github.com/PaddlePaddle/Paddle2ONNX/tree/deploykit/docs/zh/deploykit.md for more details.
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:107
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:108
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:109
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:110
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:116
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:116
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:117
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:117
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:120
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:123
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:124
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:126
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:127
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:128
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:129
The behavior of expression A + B has been unified with elementwise_add(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_add(X, Y, axis=0) instead of A + B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:72
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/generate_proposals.py:73
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py:744: DeprecationWarning: np.bool
is a deprecated alias for the builtin bool
. To silence this warning, use bool
by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_
here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
elif dtype == np.bool:
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/distribute_fpn_proposals.py:38
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/distribute_fpn_proposals.py:39
The behavior of expression A - B has been unified with elementwise_sub(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_sub(X, Y, axis=0) instead of A - B. This transitional warning will be dropped in the future.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/math_op_patch.py:341: UserWarning: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle2onnx-0.9.3-py3.7.egg/paddle2onnx/op_mapper/custom_paddle_op/distribute_fpn_proposals.py:40
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.
op_type, op_type, EXPRESSION_MAP[method_name]))
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/onnx/helper.py:343: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
is_iterable = isinstance(value, collections.Iterable)
2022-05-16 11:44:49 [WARNING] Due to the operator:multiclass_nms3, the converted ONNX model will only supports input[batch_size] == 1.
2022-05-16 11:44:52 [INFO] ONNX model generated is valid.
2022-05-16 11:44:52 [INFO] ONNX model saved in model.onnx
请问这是转换成功了吗?我看输出有些红色的提示
前三条提示忽略。 第四条提示表示导出的模型在部署预测时,只能支持单张图片的输入进行预测
前三条提示忽略。 第四条提示表示导出的模型在部署预测时,只能支持单张图片的输入进行预测
我将导出的model.onnx放到netron中查看,其输入有三个,其中scale_factor是啥意思啊?还有输出有两个,concat_6.tmp_0 是[N,6]表示N个输出结果,每个结果包含4个坐标和两个种类概率吗?(我任务前景就两类) 那么tmp_42是啥意思啊?
模型的输入输出含义请咨询PaddleDetection @gxqnba
模型的输入输出含义请咨询PaddleDetection @gxqnba
好的,非常感谢!
- 安装github上paddle2onnx的代码
- 转换时将--enable_dev_version设为False
PaddleDetection在export_model的时候,需在配置文件中添加export_onnx: True
请问一下转换时--enable_dev_version设为False, 会出现错误, 提示ModuleNotFoundError: No module named 'onnx', 这是什么问题 @jiangjiajun