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" )) |
测试正常
如果您看完本篇感觉不错,请点击下方的【推荐】支持一下博主!
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性