PaddleOCR加载chinese_ocr_db_crnn_server模型进行中英文混合预测(命令行)实践

1. 安装相关库文件
# 安装paddlehub和paddlepaddle
pip install paddlehub -i https://pypi.tuna.tsinghua.edu.cn/simple 
pip install paddlepaddle -i https://pypi.tuna.tsinghua.edu.cn/simple 
# 该Module依赖于第三方库shapely、pyclipper,使用该Module之前,请先安装shapely、pyclipper
pip install shapely -i https://pypi.tuna.tsinghua.edu.cn/simple 
pip install pyclipper -i https://pypi.tuna.tsinghua.edu.cn/simple 

使用的是清华的源,在安装时出现过https连接池超时的问题,换个网络环境,多试几次就好了。

2. 安装预训练模型

选择的是识别精度相对较高的:chinese_ocr_db_crnn_server
命令是:hub install chinese_ocr_db_crnn_server==1.1.1

(venv) E:\test\PycharmProjects\PaddleStudy2>hub install chinese_ocr_db_crnn_server==1.1.1
e:\test\pycharmprojects\paddlestudy2\venv\lib\site-packages\pip\_vendor\packaging\version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(
e:\test\pycharmprojects\paddlestudy2\venv\lib\site-packages\pip\_vendor\packaging\version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(
2021-03-16 08:50:50,784 - INFO - Lock 601713536 acquired on C:\Users\CTH\.paddlehub\tmp\chinese_ocr_db_crnn_server
[INFO 2021-03-16 08:50:50,784 filelock.py:274] Lock 601713536 acquired on C:\Users\CTH\.paddlehub\tmp\chinese_ocr_db_crnn_server
Download https://bj.bcebos.com/paddlehub/paddlehub_dev/chinese_ocr_db_crnn_server_1.1.1.tar.gz
[##################################################] 100.00%
Decompress C:\Users\CTH\.paddlehub\tmp\tmppwvzfx_9\chinese_ocr_db_crnn_server_1.1.1.tar.gz
[##################################################] 100.00%
[2021-03-16 08:51:44,000] [    INFO] - Successfully installed chinese_ocr_db_crnn_server-1.1.1
2021-03-16 08:51:44,047 - INFO - Lock 601713536 released on C:\Users\CTH\.paddlehub\tmp\chinese_ocr_db_crnn_server
[INFO 2021-03-16 08:51:44,047 filelock.py:318] Lock 601713536 released on C:\Users\CTH\.paddlehub\tmp\chinese_ocr_db_crnn_server

对应的精简版本:chinese_ocr_db_crnn_mobile
命令是:hub install chinese_ocr_db_crnn_mobile==1.1.1

3. 命令行预测

原始图片:
在这里插入图片描述

命令是:hub run chinese_ocr_db_crnn_server --input_path “/PATH/TO/IMAGE”

(venv) E:\test\PycharmProjects\PaddleStudy2>hub run chinese_ocr_db_crnn_server --input_path "E:/test/PycharmProjects/PaddleStudy2/pic/0-1.jpg"
e:\test\pycharmprojects\paddlestudy2\venv\lib\site-packages\pip\_vendor\packaging\version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(
e:\test\pycharmprojects\paddlestudy2\venv\lib\site-packages\pip\_vendor\packaging\version.py:127: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  warnings.warn(
[2021-03-16 08:53:25,582] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
W0316 08:53:25.598523 12472 analysis_predictor.cc:1145] Deprecated. Please use CreatePredictor instead.
2021-03-16 08:53:26,440 - INFO - Lock 607078624 acquired on C:\Users\CTH\.paddlehub\tmp\chinese_text_detection_db_server
[INFO 2021-03-16 08:53:26,440 filelock.py:274] Lock 607078624 acquired on C:\Users\CTH\.paddlehub\tmp\chinese_text_detection_db_server
Download https://bj.bcebos.com/paddlehub/paddlehub_dev/chinese_text_detection_db_server_1.0.2.tar.gz
[##################################################] 100.00%
Decompress C:\Users\CTH\.paddlehub\tmp\tmpvc1k5tyo\chinese_text_detection_db_server_1.0.2.tar.gz
[##################################################] 100.00%
[2021-03-16 08:53:55,071] [    INFO] - Successfully installed chinese_text_detection_db_server-1.0.2
2021-03-16 08:53:55,118 - INFO - Lock 607078624 released on C:\Users\CTH\.paddlehub\tmp\chinese_text_detection_db_server
[INFO 2021-03-16 08:53:55,118 filelock.py:318] Lock 607078624 released on C:\Users\CTH\.paddlehub\tmp\chinese_text_detection_db_server
[2021-03-16 08:53:55,118] [ WARNING] - The _initialize method in HubModule will soon be deprecated, you can use the __init__() to handle the initialization of the object
[{'save_path': '', 'data': [{'text': '双耳机配对', 'confidence': 0.9995235204696655, 'text_box_position': [[64, 63], [301, 69], [299, 119], [63, 113]]}, {'text': '首次配对方法:', 'confidence': 0.9997860193252563, 'text_box_position':
[[71, 186], [336, 194], [334, 232], [70, 225]]}, {'text': '1、取出两只耳机,再将两只耳机放回充电盒中', 'confidence': 0.9993939399719238, 'text_box_position': [[67, 245], [767, 258], [767, 297], [67, 283]]}, {'text': '(此步骤为新机激活
)', 'confidence': 0.9379152655601501, 'text_box_position': [[116, 293], [411, 300], [410, 335], [115, 328]]}, {'text': '2、再次取出两只耳机', 'confidence': 0.999390721321106, 'text_box_position': [[67, 339], [401, 349], [399, 384], [6
6, 374]]}, {'text': '3、刷新手机蓝牙设备列表,点击配对QCY-T1C,完成配对', 'confidence': 0.9993934035301208, 'text_box_position': [[67, 388], [937, 402], [937, 437], [67, 422]]}, {'text': '耳机取出会自动开机,若未自动开机,请充电后重新
尝试', 'confidence': 0.990841269493103, 'text_box_position': [[80, 436], [938, 451], [938, 483], [80, 468]]}, {'text': '切换设备配对方法:', 'confidence': 0.9996602535247803, 'text_box_position': [[71, 536], [421, 536], [421, 573], [71
, 573]]}, {'text': '1、关闭A手机蓝牙,耳机自动断开进入配对模式', 'confidence': 0.9853517413139343, 'text_box_position': [[67, 590], [791, 598], [791, 636], [67, 629]]}, {'text': '2、刷新B手机蓝牙设备列表,点击配对QCY-T1C,完成配对', 'c
onfidence': 0.9961883425712585, 'text_box_position': [[63, 638], [964, 649], [964, 695], [63, 684]]}, {'text': '*不支持同时连接两台手机,下次开机默认回连上次配对的手机', 'confidence': 0.9984445571899414, 'text_box_position': [[73, 686]
, [989, 698], [989, 748], [73, 736]]}]}]

结果:

{
‘text’: ‘双耳机配对’,
‘confidence’: 0.9995235204696655,
‘text_box_position’: [[64, 63], [301, 69], [299, 119], [63, 113]]
},
{
‘text’: ‘首次配对方法:’,
‘confidence’: 0.9997860193252563,
‘text_box_position’: [[71, 186], [336, 194], [334, 232], [70, 225]]
},
{
‘text’: ‘1、取出两只耳机,再将两只耳机放回充电盒中’,
‘confidence’: 0.9993939399719238,
‘text_box_position’: [[67, 245], [767, 258], [767, 297], [67, 283]]
},
{
‘text’: ‘(此步骤为新机激活)’,
‘confidence’: 0.9379152655601501,
‘text_box_position’: [[116, 293], [411, 300], [410, 335], [115, 328]]
},
{
‘text’: ‘2、再次取出两只耳机’,
‘confidence’: 0.999390721321106,
‘text_box_position’: [[67, 339], [401, 349], [399, 384], [66, 374]]
},
{
‘text’: ‘3、刷新手机蓝牙设备列表,点击配对QCY-T1C,完成配对’,
‘confidence’: 0.9993934035301208,
‘text_box_position’: [[67, 388], [937, 402], [937, 437], [67, 422]]
},
{
‘text’: ‘耳机取出会自动开机,若未自动开机,请充电后重新尝试’,
‘confidence’: 0.990841269493103,
‘text_box_position’: [[80, 436], [938, 451], [938, 483], [80, 468]]
},
{
‘text’: ‘切换设备配对方法:’,
‘confidence’: 0.9996602535247803,
‘text_box_position’: [[71, 536], [421, 536], [421, 573], [71, 573]]
},
{
‘text’: ‘1、关闭A手机蓝牙,耳机自动断开进入配对模式’,
‘confidence’: 0.9853517413139343,
‘text_box_position’: [[67, 590], [791, 598], [791, 636], [67, 629]]
},
{
‘text’: ‘2、刷新B手机蓝牙设备列表,点击配对QCY-T1C,完成配对’,
‘confidence’: 0.9961883425712585,
‘text_box_position’: [[63, 638], [964, 649], [964, 695], [63, 684]]
},
{
‘text’: ‘*不支持同时连接两台手机,下次开机默认回连上次配对的手机’,
‘confidence’: 0.9984445571899414,
‘text_box_position’: [[73, 686], [989, 698], [989, 748], [73, 736]]
}

识别效果非常好!!!

【参考文档】
PaddleHub一键OCR中文识别
PaddleHub

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
受到大佬项目 免root跨平台自动化测试框架webrebot 本地离线OCR的启发和指引,成功的把百度开源的 PaddleOCR 应用到PYTHON及VC++ 经过小范围测试python的效果比VC++理想很多,绝大多数游戏及日常都可以成功通用识别. 更新添加DLL版本了 在网盘里已经更新了VC++的 DLL版本,及VC++调用测试的!知道易语言 怎么调用64位DLL的也发个例子吧 注: PYTHON代码里还用到了两个组件要在按下面的安装完成PaddlePaddlePaddleOCR后再执行两个命令才能使用 fastapi 一个异步的超强WEB框架 1、python -m pip install fastapi 2、python -m pip install uvicorn 游戏小图识别成功率比较高 大图测试 python部分代码: python 的安装很多的坑..在期间找了无数贴子。。自己把经验总结分享 一、安装python         安装3.7或者3.8 python         我的安装环境是 WIN10 X64 PYTHON 3.85 二、安装PaddlePaddle 升级PIP  python -m pip install --upgrade pip         如果您的机器安装的是CUDA9或CUDA10,请运行以下命令安装         python -m pip install paddlepaddle-gpu -i https://mirror.baidu.com/pypi/simple         如果您的机器是CPU,请运行以下命令安装, 工作室或者GPU不太好的就用这个, 正常也使用这个就好了         python -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple 三、克隆\安装PaddleOCR代码         方法一:                git clone https://gitee.com/paddlepaddle/PaddleOCR                 安装第三方库                 cd PaddleOCR                 python -m pip install -r requirments.txt         方法二:                 pip install paddleocr -i https://mirror.baidu.com/pypi/simple PS:95% 运行不成功的问题, 是在这步造成的         安装完成后 再执行 更新 默认安装的numpy版本太高。。 python -m pip install numpy==1.19.3 -i https://mirror.baidu.com/pypi/simple 四、目前PYTHON的识别比C++的高 另附上VC++的识别图 VC++版本因为太大(几个文件,无需安装,命令行取回显方式调用)和PYTHON识别库上传到BAIDU网盘中 链接: https://pan.baidu.com/s/1jC7wgx7hiQ-FsYluiIKukQ  提取码: gycx

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

皓月如我

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值