Pycharm+win10安装PaddleOCR

2 篇文章 0 订阅

1.升级pip

python -m pip install --upgrade pip

2.跟着官网快速安装深度学习框架--paddlepaddle,我安装的是cpu版本

开始使用_飞桨-源于产业实践的开源深度学习平台 (paddlepaddle.org.cn)

3.git paddleocr套件

git clone https://github.com/PaddlePaddle/PaddleOCR.git

4.下载完毕进入PaddleOCR文件夹,并安装

cd PaddleOCR
python -m pip install -r requirements.txt
或采用镜像
pip install -r requirments.txt -i https://mirror.baidu.com/pypi/simple

PS:可能会报找不到文件的错误

Could not open requirements file: [Errno 2] No such file or directory: 'requirments.txt'

解决办法:跟着网上的教程,重新安装依赖库--shapely

#卸载Shapely
pip uninstall shapely

#重新安装Shapely
pip install Shapely-1.7.1-cp37-cp37m-win_amd64.whl

#重新安装
pip install -r requirements.txt
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple paddleocr

又报错了,提示要求protobuf版本要低于3.20.2,高于3.1.0,这个可以不管,因为后续又报错了

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This be
haviour is the source of the following dependency conflicts.
paddlepaddle 2.5.1 requires protobuf<=3.20.2,>=3.1.0; platform_system == "Windows", but you have protobuf 4.24.2 w
hich is incompatible.

解决办法:重新安装即可,安装大于等于3.19.0的版本,不然可能会遇到以下错误

pip install protobuf==3.19.0

5.测试安装是否成功

(1)查看官方测试代码

PaddleOCR/doc/doc_ch/whl.md at static · PaddlePaddle/PaddleOCR · GitHub

(2)查看图片

import matplotlib.pyplot as plt
from PIL import Image

## 显示原图,读取名称为1.jpg的测试图像
img_path= "./photo/1.jpg"
img = Image.open(img_path)
plt.figure("test_img", figsize=(10,10))
plt.imshow(img)
plt.show()

通过该笔者写法解决draw_ocr出错问题:

paddleOCR中示例draw_ocr出错问题解决_Blackrosetian的博客-CSDN博客

from paddleocr import PaddleOCR, draw_ocr

# Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
# 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
result = ocr.ocr(img_path, cls=True)
for line in result:
    print(line)

# 显示结果
from PIL import Image
image = Image.open(img_path).convert('RGB')
boxes = [detection[0] for line in result for detection in line] # Nested loop added
txts = [detection[1][0] for line in result for detection in line] # Nested loop added
scores = [detection[1][1] for line in result for detection in line] # Nested loop added
im_show = draw_ocr(image, boxes, txts, scores)
im_show = Image.fromarray(im_show)

得到识别结果: 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值