ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PaddleOCR 识别使用遇到的问题

2020-12-29 15:58:27  阅读:2065  来源: 互联网

标签:遇到 python PaddleOCR Levenshtein paddle build install line 识别


PaddleOCR 识别使用遇到的问题

文章目录

前言

识别时用的代码,注意更改图片地址

博文:PaddleOCR简单使用,识别文字测试

我是用PyCharm IDE

from paddleocr import PaddleOCR, draw_ocr

# 模型路径下必须含有model和params文件,如果没有,现在可以自动下载了,不过是最简单的模型
# use_gpu 如果paddle是GPU版本请设置为 True
ocr = PaddleOCR(use_angle_cls=True, use_gpu=False)

img_path = 'D:/PythonCode/paddle/ocr/11.jpg'  # 这个是自己的图片,自行放置在代码目录下修改名称

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 = [line[0] for line in result]
txts = [line[1][0] for line in result]
scores = [line[1][1] for line in result]
im_show = draw_ocr(image, boxes, txts, scores)
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')  # 结果图片保存在代码同级文件夹中。

错误1:AttributeError: module ‘paddle.distributed’ has no attribute ‘get_rank’

这个是@我是你杰哥遇到的

这个是安装问题

他的回复

首先得保证Python是3.7版本,3.6的都不行,然后安装paddle,然后按照说明安装shapely也得对应Python版本,最后安装这个paddleocr包2.0.1或者2.0.2版本

可以参考我的安装博文重新安装

PaddleoOCR环境配置与安装

https://blog.csdn.net/qq_38463737/article/details/111890057

错误2:OSError: [WinError 126] 找不到指定的模块。

image-20201229122838835

这个可能也是安装问题

可以参考我的安装博文重新安装

PaddleoOCR环境配置与安装

https://blog.csdn.net/qq_38463737/article/details/111890057

错误3。 error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/

完整错误文本


ERROR: Command errored out with exit status 1:
command: ‘d:\code_python\paddle_2\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\mgboy\AppData\Local\Temp\pip-inst
all-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’; file=’"’"‘C:\Users\mgboy\AppData\Local\Temp\pip-install-9t28wbny\python-levensh
tein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(
compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\mgboy\AppData\Local\Temp\pip-record-x3h79u3f\install-record.txt’ --single-version-externally-managed –
compile --install-headers ‘d:\code_python\paddle_2\venv\include\site\python3.7\python-Levenshtein’
cwd: C:\Users\mgboy\AppData\Local\Temp\pip-install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc
Complete output (27 lines):
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\Levenshtein
copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.7\Levenshtein
copying Levenshtein_init_.py -> build\lib.win-amd64-3.7\Levenshtein
running egg_info
writing python_Levenshtein.egg-info\PKG-INFO
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt
writing entry points to python_Levenshtein.egg-info\entry_points.txt
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt
writing requirements to python_Levenshtein.egg-info\requires.txt
writing top-level names to python_Levenshtein.egg-info\top_level.txt
reading manifest file ‘python_Levenshtein.egg-info\SOURCES.txt’
reading manifest template ‘MANIFEST.in’
warning: no previously-included files matching ‘*pyc’ found anywhere in distribution
warning: no previously-included files matching ‘*so’ found anywhere in distribution
warning: no previously-included files matching ‘.project’ found anywhere in distribution
warning: no previously-included files matching ‘.pydevproject’ found anywhere in distribution
writing manifest file ‘python_Levenshtein.egg-info\SOURCES.txt’
copying Levenshtein_levenshtein.c -> build\lib.win-amd64-3.7\Levenshtein
copying Levenshtein_levenshtein.h -> build\lib.win-amd64-3.7\Levenshtein
running build_ext
building ‘Levenshtein._levenshtein’ extension

error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Command errored out with exit status 1: ‘d:\code_python\paddle_2\venv\scripts\python.exe’ -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"‘C:\Users\mgbo
y\AppData\Local\Temp\pip-install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’; file=’"’"‘C:\Users\mgboy\AppData\Local\Temp\pip
-install-9t28wbny\python-levenshtein_13c216c123594819b0c3e6a2680b39cc\setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’
“’, '”’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record ‘C:\Users\mgboy\AppData\Local\Temp\pip-record-x3h79u3f\install-record.txt’ --sin
gle-version-externally-managed --compile --install-headers ‘d:\code_python\paddle_2\venv\include\site\python3.7\python-Levenshtein’ Check the logs for full command output.


解决方法

https://visualstudio.microsoft.com/visual-cpp-build-tools/

下载Microsoft C++ Build Tools

image-20201229123916947

下载有点慢,请耐心

运行exe文件

image-20201229124156493

选择安装的内容(不清楚就按下面选择)

image-20201229124306222

更改安装地址,(把下面红框能改的推荐改一下,改到一个容量大的盘,比如我D盘)

image-20201229124415680

然后点击右下角安装按钮

安装包很大,请慢慢等吧,

错误4.AttributeError: module ‘paddleocr’ has no attribute ‘PaddleOCR’

这个也是安装有问题,可能是项目内的Python包有冲突

可以参考我的安装博文重新安装

PaddleoOCR环境配置与安装

https://blog.csdn.net/qq_38463737/article/details/111890057

错误5.[2020/12/29 10:51:41] root ERROR: error in loading image:11.jpg(xx图片)

W1229 10:51:40.596693 9548 analysis_predictor.cc:1058] Deprecated. Please use CreatePredictor instead.
[2020/12/29 10:51:41] root ERROR: error in loading image:11.jpg
Traceback (most recent call last):
File “D:/PythonCode/paddle/ocr/testocr.py”, line 8, in
for line in result:
TypeError: ‘NoneType’ object is not iterable


这个是我尝试使用CMD运行出现的错误

 C:\Anaconda3\envs\paddle3.7\python.exe D:/PythonCode/paddle/ocr/testocr.py

第一个Python编译器很重要,是你安装paddleocr的编译器地址

解决

这是由于识别代码中的图片使用的地址是相对地址

把它改成绝对地址即可

image-20201229125458497

标签:遇到,python,PaddleOCR,Levenshtein,paddle,build,install,line,识别
来源: https://blog.csdn.net/qq_38463737/article/details/111922162

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有