PaddlePaddle / models

Officially maintained, supported by PaddlePaddle, including CV, NLP, Speech, Rec, TS, big models and so on.
Apache License 2.0
6.88k stars 2.91k forks source link

SMOKE static model export to ONNX #5394

Open Gewaihir opened 2 years ago

Gewaihir commented 2 years ago

Dear Author. Hello! I have encountered a problem. I am using the SMOKE model and following the instructions in README.MD to export the model as a static diagram model. However, the following error occurs when converting the static diagram model to ONNX model.

/home/lee/.conda/envs/paddle/lib/python3.8/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)
/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/constant/dtypes.py:45: 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
  np.bool: core.VarDesc.VarType.BOOL,
/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/constant/dtypes.py:46: DeprecationWarning: `np.float` is a deprecated alias for the builtin `float`. To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  core.VarDesc.VarType.FP32: np.float,
/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/constant/dtypes.py:51: 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
  core.VarDesc.VarType.BOOL: np.bool
Traceback (most recent call last):
  File "/home/lee/.conda/envs/paddle/bin/paddle2onnx", line 8, in <module>
    sys.exit(main())
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/command.py", line 148, in main
    program2onnx(
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/command.py", line 114, in program2onnx
    p2o.program2onnx(
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/convert.py", line 79, in program2onnx
    export_onnx(paddle_graph, save_file, opset_version, enable_onnx_checker, operator_export_type)
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/convert.py", line 33, in export_onnx
    onnx_graph = ONNXGraph.build(paddle_graph, opset_version, operator_export_type, verbose)
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/graph/onnx_graph.py", line 240, in build
    onnx_graph = ONNXGraph(paddle_graph, opset_version=opset_version, operator_export_type=operator_export_type)
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/graph/onnx_graph.py", line 79, in __init__
    self.update_opset_version()
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/graph/onnx_graph.py", line 194, in update_opset_version
    self.opset_version = OpMapper.get_recommend_opset_version(node_map, self.opset_version)
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/op_mapper/op_mapper.py", line 127, in get_recommend_opset_version
    recommend_opset_version = OpMapper.check_support_status(node_map, opset_version, True)
  File "/home/lee/.conda/envs/paddle/lib/python3.8/site-packages/paddle2onnx/op_mapper/op_mapper.py", line 168, in check_support_status
    raise NotImplementedError(error_info)
NotImplementedError: 
There's 9 ops are not supported yet
=========== while ===========
=========== set_value ===========
=========== crop_tensor ===========
=========== logical_not ===========
=========== less_than ===========
=========== select_input ===========
=========== conditional_block ===========
=========== index_select ===========
=========== atan ===========

This error indicates that nine operators are not supported. After checking the list of operators, I found only 'conditional-block', 'set-value', and 'while', 'select-input' and 'crop-tensor' are not available. Here are the commands I used for the conversion. paddle2onnx --model_dir /media/lee/DATA/project/gitproject/models/PaddleCV/3d_vision/SMOKE/inference_model --model_filename inference.pdmodel --params_filename inference.pdiparams --opset_version 11 --save_file smoke.onnx How should I solve such a situation? I look forward to your reply!

jiangjiajun commented 2 years ago

Duplicate of https://github.com/PaddlePaddle/Paddle2ONNX/issues/407