这款很好用的工具项目地址为:https://github.com/breezedeus/cnstd
目前基于PyTorch开发
首先需要安装相关依赖:
pip install cnstd
pip install cnocr
我们采用以下图片进行测试,命名为lining.png:

运行样例测试程序:
from cnstd import CnStd
from cnocr import CnOcr
std = CnStd()
cn_ocr = CnOcr()
box_infos = std.detect('../examples/lining.png', resized_shape=(768, 1024))
print(len(box_infos['detected_texts']))
for box_info in box_infos['detected_texts']:
cropped_img = box_info['cropped_img']
ocr_res = cn_ocr.ocr_for_single_line(cropped_img)
print('ocr result: %s' % str(ocr_res))
模型需要先对图片进行缩放,之后才能进行预测,其中,std.detect 的 resized_shape 可以自行设置,但必须是32的倍数,此处设置为跟图片自身分辨率接近的值:(768, 1024))运行程序后,报错为:
Traceback (most recent call last):
File "D:/dev/cnstd-master/test

最低0.47元/天 解锁文章
589

被折叠的 条评论
为什么被折叠?



