当前位置:   article > 正文

Pycharm+win10安装PaddleOCR_pycharm 无法安装 paddleocr

pycharm 无法安装 paddleocr

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文件夹,并安装

  1. cd PaddleOCR
  2. python -m pip install -r requirements.txt
  3. 或采用镜像
  4. 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

  1. #卸载Shapely
  2. pip uninstall shapely
  3. #重新安装Shapely
  4. pip install Shapely-1.7.1-cp37-cp37m-win_amd64.whl
  5. #重新安装
  6. pip install -r requirements.txt
  7. 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)查看图片

  1. import matplotlib.pyplot as plt
  2. from PIL import Image
  3. ## 显示原图,读取名称为1.jpg的测试图像
  4. img_path= "./photo/1.jpg"
  5. img = Image.open(img_path)
  6. plt.figure("test_img", figsize=(10,10))
  7. plt.imshow(img)
  8. plt.show()

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

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

  1. from paddleocr import PaddleOCR, draw_ocr
  2. # Paddleocr目前支持中英文、英文、法语、德语、韩语、日语,可以通过修改lang参数进行切换
  3. # 参数依次为`ch`, `en`, `french`, `german`, `korean`, `japan`。
  4. ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
  5. result = ocr.ocr(img_path, cls=True)
  6. for line in result:
  7. print(line)
  8. # 显示结果
  9. from PIL import Image
  10. image = Image.open(img_path).convert('RGB')
  11. boxes = [detection[0] for line in result for detection in line] # Nested loop added
  12. txts = [detection[1][0] for line in result for detection in line] # Nested loop added
  13. scores = [detection[1][1] for line in result for detection in line] # Nested loop added
  14. im_show = draw_ocr(image, boxes, txts, scores)
  15. im_show = Image.fromarray(im_show)

得到识别结果: 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/946185
推荐阅读
相关标签
  

闽ICP备14008679号