地址: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.....