DayBreak-u / chineseocr_lite

超轻量级中文ocr,支持竖排文字识别, 支持ncnn、mnn、tnn推理 ( dbnet(1.8M) + crnn(2.5M) + anglenet(378KB)) 总模型仅4.7M
GNU General Public License v2.0
11.8k stars 2.26k forks source link

群主,更新的时候,可以把ncnn转换的模型,也上传一下不? #236

Open xinsuinizhuan opened 4 years ago

DayBreak-u commented 4 years ago

有onnx模型,可以自己转哦

xinsuinizhuan commented 4 years ago

我看您的onnx分支,识别没有做方向判断,直接是crnn_lstm模型进行识别。但是master分支里面,检测区域检测出来后,先做方向判断,然后旋转后进行识别。是onnx不需要做了吗,直接支持方向字体识别吗?

xinsuinizhuan commented 4 years ago

有onnx模型,可以自己转哦

另外,我尝试过,直接使用ncnn中的onnx2ncnn转crnn_lstm和crnn_lstm_lite时,提示操作不支持,但是看niuhui大神的手动修改,没看懂。是即使转换后有些模型提示不支持,然后自己手动打开parms文件,直接修改reshape等操作吗?

DayBreak-u commented 4 years ago

@xinsuinizhuan 竖排横排都是支持的,正反方向onnx还不支持

xinsuinizhuan commented 4 years ago

@xinsuinizhuan 竖排横排都是支持的,正反方向onnx还不支持

您这边方便转换吗?我这边尝试过转换,确实是一直提示不支持。 我这边使用ncnn的onnx2ncnn直接转换日志如下: Shape not supported yet! Gather not supported yet!

axis=0

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! ConstantOfShape not supported yet!

value 4

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Shape not supported yet! Gather not supported yet!

axis=0

Shape not supported yet! Gather not supported yet!

axis=0

Shape not supported yet! Gather not supported yet!

axis=0

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unknown data type 0 Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unknown data type 0 Shape not supported yet! Gather not supported yet!

axis=0

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! ConstantOfShape not supported yet!

value 4

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Shape not supported yet! Gather not supported yet!

axis=0

Shape not supported yet! Gather not supported yet!

axis=0

Shape not supported yet! Gather not supported yet!

axis=0

Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unknown data type 0 Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unsupported unsqueeze axes ! Unknown data type 0

I:\NCNN\ncnn\tencent_ncnn\ncnn-master\build\tools\Release\onnx2ncnn.exe (进程 13704)已退出,代码为 0。 要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。 按任意键关闭此窗口. . .

DayBreak-u commented 4 years ago

@xinsuinizhuan 先处理一下 https://github.com/daquexian/onnx-simplifier

xinsuinizhuan commented 4 years ago

@xinsuinizhuan 先处理一下 https://github.com/daquexian/onnx-simplifier 第一步 安装pip install onnx-simplifier 第二步: (base37) C:\WINDOWS\system32>python -m onnxsim I:\OCR\chineseocr_lite-onnx\models\crnn_lstm.onnx I:\OCR\chineseocr_lite-onnx\models\crnn_lstm_ex.onnx Simplifying... Traceback (most recent call last): File "E:\ProgramData\Anaconda3\envs\base37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "E:\ProgramData\Anaconda3\envs\base37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim__main.py", line 52, in main() File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\main__.py", line 40, in main args.input_model, check_n=args.check_n, perform_optimization=not args.skip_optimization, skip_fuse_bn=not args.enable_fuse_bn, input_shapes=input_shapes, skipped_optimizers=args.skip_optimizer, skip_shape_inference=args.skip_shape_inference) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 331, in simplify model, const_nodes, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 172, in forward_for_node_outputs res = forward(model, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 157, in forward inputs = generate_rand_input(model, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 108, in generate_rand_input 'please determine the input size manually by --input-shape xxx'.format(key)) RuntimeError: The shape of input "input" has dynamic size, please determine the input size manually by --input-shape xxx

报错,不知道是哪儿有问题?需要加什么参数吗?

xinsuinizhuan commented 4 years ago

https://github.com/ouyanghuiyu/chineseocr_lite/issues/236#issuecomment-675221959 楼主,可以帮帮看一下吗?我这边要C++加载试试模型,C++进行部署测试。但是现在模型无法转换。

ZZHHogan commented 4 years ago

@xinsuinizhuan 先处理一下 https://github.com/daquexian/onnx-simplifier 第一步 安装pip install onnx-simplifier 第二步: (base37) C:\WINDOWS\system32>python -m onnxsim I:\OCR\chineseocr_lite-onnx\models\crnn_lstm.onnx I:\OCR\chineseocr_lite-onnx\models\crnn_lstm_ex.onnx Simplifying... Traceback (most recent call last): File "E:\ProgramData\Anaconda3\envs\base37\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "E:\ProgramData\Anaconda3\envs\base37\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsimmain.py", line 52, in main() File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsimmain.py", line 40, in main args.input_model, check_n=args.check_n, perform_optimization=not args.skip_optimization, skip_fuse_bn=not args.enable_fuse_bn, input_shapes=input_shapes, skipped_optimizers=args.skip_optimizer, skip_shape_inference=args.skip_shape_inference) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 331, in simplify model, const_nodes, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 172, in forward_for_node_outputs res = forward(model, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 157, in forward inputs = generate_rand_input(model, input_shapes=input_shapes) File "E:\ProgramData\Anaconda3\envs\base37\lib\site-packages\onnxsim\onnx_simplifier.py", line 108, in generate_rand_input 'please determine the input size manually by --input-shape xxx'.format(key)) RuntimeError: The shape of input "input" has dynamic size, please determine the input size manually by --input-shape xxx

报错,不知道是哪儿有问题?需要加什么参数吗?

你好 我这里也遇到一样的问题,请问你解决了吗?

smilealvin92 commented 2 years ago

#236 (comment) 楼主,可以帮帮看一下吗?我这边要C++加载试试模型,C++进行部署测试。但是现在模型无法转换。

这位老师,您的问题解决了吗,我用x86下面的python3.8.13的0.4.1的onnx-simplifier能够实现简化,但是还是有几个胶水op没有解决,大部分胶水op确实去掉了

smilealvin92 commented 2 years ago

解决了,可以参考已有 param模型去手动编辑新产生的模型,但是我基于20220721版本的ncnn编译出来的模型,经过修改后,虽然能够加载,但是推理出来的文本是错的,这个目前还没找到原因