paddleocr报错解决方案汇总

一、安装注意事项

python不要超过10,尽量选8/9/10

二、快速开始

参考官方文档:https://paddlepaddle.github.io/PaddleOCR/main/ppstructure/quick_start.html#221

一般都要带方向识别,这里复制其中一段代码,防止官网挂掉

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import cv2
from paddleocr import PPStructure,draw_structure_result,save_structure_res
 
table_engine = PPStructure(show_log=True, image_orientation=True)
 
save_folder = './output'
img_path = 'ppstructure/docs/table/1.png'
img = cv2.imread(img_path)
result = table_engine(img)
save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])
 
for line in result:
    line.pop('img')
    print(line)
 
from PIL import Image
 
font_path = 'doc/fonts/simfang.ttf' # PaddleOCR下提供字体包
image = Image.open(img_path).convert('RGB')
im_show = draw_structure_result(image, result,font_path=font_path)
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

三、paddleclas报错

使用方向分类要设置 image_orientation=True

按报错提示,安装 paddleclas,但是后续还是报错不存在,这里其实是安装文件本身的bug

参考:bugfix for deploy by TingquanGao · Pull Request #3313 · PaddlePaddle/PaddleClas · GitHub

一个是修改 deploy/utils/predictor.py,文件在虚拟环境里,可以通过 pip show paddleclas 来查看路径

将第58行-第62行

1
2
3
4
5
pd_version = 0
for v in paddle.__version__.split(".")[:3]:
    pd_version = 10 * pd_version + eval(v)
 
if pd_version == 0 or pd_version >= 260:

替换为

1
2
3
major_v, minor_v, _ = paddle.__version__.split(".")[:3]
major_v, minor_v = int(major_v), int(minor_v)
if (major_v == 0 and minor_v == 0) or (major_v >= 3):

另一个是 paddleclas.py

第49行

1
BASE_DIR = os.path.expanduser("~/.paddleclas/")

替换为

1
BASE_DIR = os.path.expanduser(os.path.join("~", ".paddleclas"))

测试正常

posted @   平底斜  阅读(57)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
点击右上角即可分享
微信分享提示