百度開源:PaddleOCR與PaddlePaddle / paddle2onnx 實踐一


地址:https://github.com/PaddlePaddle/PaddleOCR 

OCR toolkit based on PaddlePaddle (基於飛槳的OCR工具庫,包含總模型僅8.6M的超輕量級中文OCR,同時支持多種文本檢測、文本識別的訓練算法。)

嘗試將paddleOCR項目中的文字檢測模型使用PaddlePaddle/paddle2onnx轉換成通用框架模型onnx

目前遇到幾個問題:

1.

node_proto = ops.node_maker[str(op.type)](operator=op, block=block)
該行運行到最后一個block時 node_maker中對應值為
'hard_sigmoid': 'HardSigmoid',  # Caffe2 error

就會報str是不可以調用的錯誤。
目前我的改進辦法是遇到hard_sigmoid節點名稱強變為'HardSigmoid'后append到onnx_nodes里。

這個問題解決后遇到第二個:

2.

----------- Configuration Arguments -----------
check_task: image_classification
debug: False
fluid_model: D:/work/Paddle/inference/det/
fluid_model_name: model
fluid_params_name: params
image_path:
name_prefix:
onnx_model: D:\work\\Paddle\inference\det
return_variable: False
to_print_model: False
------------------------------------------------
load the model parameter done.
The operator sets to run test case.
{'hard_swish', 'batch_norm', 'elementwise_sub', 'scale', 'elementwise_add', 'relu', 'hard_sigmoid', 'pool2d', 'concat', 'exp', 'elementwise_mul', 'conv2d_transpose', 'sigmoid', 'depthwise_conv2d', 'conv2d', 'reciprocal', 'nearest_interp'}
dict_items([('producer_name', 'PaddlePaddle')])
Traceback (most recent call last):
File "D:/work//paddle2onnx-develop/paddle2onnx-develop/fluid_onnx/fluid_to_onnx.py", line 238, in <module>
main()
File "D:/work/paddle2onnx-develop/paddle2onnx-develop/fluid_onnx/fluid_to_onnx.py", line 234, in main
convert(args)
File "D:/work/paddle2onnx-develop/paddle2onnx-develop/fluid_onnx/fluid_to_onnx.py", line 198, in convert
checker.check_model(onnx_model)
File "D:\setup\Anaconda3\envs\py361\lib\site-packages\onnx\checker.py", line 91, in check_model
C.check_model(model.SerializeToString())
onnx.onnx_cpp2py_export.checker.ValidationError: Nodes in a graph must be topologically sorted, however input 'hard_swish_0.tmp_0' of node:
input: "hard_swish_0.tmp_0" input: "conv2_expand_weights" output: "conv2d_1.tmp_0" op_type: "Conv" attribute { name: "dilations" ints: 1 ints: 1 type: INTS } attribute { name: "group" i: 1 type: INT } attribute { name: "kernel_shape" ints: 1 ints: 1 type: INTS } attribute { name: "pads" ints: 0 ints: 0 ints: 0 ints: 0 type: INTS } attribute { name: "strides" ints: 1 ints: 1 type: INTS }
is not output of any previous nodes.

查了很多資料有的說是onnx的問題,有的說是paddle2onnx還沒有支持某些OP.....

問題參考鏈接:https://github.com/PaddlePaddle/paddle2onnx/issues?q=ValidationError%3A+Nodes+in+a+graph+must+be+topologically+sorted


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM