百度飞浆OCR识别表格入门python实践

这篇具有很好参考价值的文章主要介绍了百度飞浆OCR识别表格入门python实践。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

1. 百度飞桨(PaddlePaddle)

百度飞桨(PaddlePaddle)是百度推出的一款深度学习平台,旨在为开发者提供强大的深度学习框架和工具。飞桨提供了包括OCR(光学字符识别)在内的多种功能,可以帮助开发者在各种应用中实现高效的文本识别。官网链接:https://www.paddlepaddle.org.cn/。

百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR

初次使用,安装:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple paddlepaddle

验证安装,使用 python 进入 python 解释器,输入 import paddle ,再输入 paddle.utils.run_check()。

python
Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import paddle
paddle.utils.run_check()
Running verify PaddlePaddle program …
I0904 17:11:21.570567 15712 interpretercore.cc:237] New Executor is Running.
I0904 17:11:21.702833 15712 interpreter_util.cc:518] Standalone Executor is Used.
PaddlePaddle works well on 1 CPU.
PaddlePaddle is installed successfully! Let’s start deep learning with PaddlePaddle now.

2. 飞桨OCR

飞桨文字识别开发套件PaddleOCR,旨在打造一套丰富、领先且实用的OCR工具库,开源了基于PP-OCR实用的超轻量中英文OCR模型、通用中英文OCR模型,以及德法日韩等多语言OCR模型。并提供上述模型训练方法和多种预测部署方式。同时开源文本风格数据合成工具Style-Text和半自动文本图像标注工具PPOCRLable。

飞桨OCR文字简明识别过程如下图所示。
百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR

2.1. 安装飞桨OCR

如果你有企业中明确的 OCR 垂类应用需求,我们推荐你使用训压推一站式全流程高效率开发平台 PaddleX,助力 AI 技术快速落地。

首先,下载shapely安装包(地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/),并安装。

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple e:\software\python\Shapely-1.8.2-cp38-cp38-win_amd64.whl

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple paddleocr

通用OCR文字识别,首个样例。

百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR

from paddleocr import PaddleOCR, draw_ocr

# Paddleocr目前支持的多语言语种可以通过修改lang参数进行切换
# 例如`ch`, `en`, `fr`, `german`, `korean`, `japan`
ocr = PaddleOCR(use_angle_cls=True, lang="ch")  # need to run only once to download and load model into memory
img_path = './imgs/11.jpg'
result = ocr.ocr(img_path, cls=True)
for idx in range(len(result)):
    res = result[idx]
    for line in res:
        print(line)

# 显示结果
from PIL import Image
result = result[0]
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, font_path='./fonts/simfang.ttf')
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')

百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR
我的python环境,供参考:

  • 操作系统:windows 10 专业版 版本 22H2
  • python 3.8.10
  • 安装包内容如下详见附件

2.2. PP-Structure 快速开始

PP-Structure是一个基于PaddlePaddle的表格结构识别工具包,可以帮助开发者快速进行表格结构的识别和提取。

图表识别,输入图像如下图,带水印的网页表格:
百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR
官方示例代码:

import os
import cv2
from paddleocr import PPStructure,draw_structure_result,save_structure_res

table_engine = PPStructure(show_log=True)

save_folder = 'output'
img_path = 'img/12.jpg'
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 = 'C:\Windows\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('result2.jpg')

百度飞浆OCR识别表格入门python实践,Python,人工智能及Python,百度,ocr,python,PaddleOCR

download https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar to 
C:\Users\xiaoyw/.paddleocr/whl\table\ch_ppstructure_mobile_v2.0_SLANet_infer\ch_ppstructure_mobile_v2.0_SLANet_infer.tar
100%| 10.3M/10.3M [00:01<00:00, 6.69MiB/s]
download https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar to 
C:\Users\xiaoyw/.paddleocr/whl\layout\picodet_lcnet_x1_0_fgd_layout_cdla_infer\picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar
100%|| 10.1M/10.1M [00:00<00:00, 10.2MiB/s]

参考:

VipSoft. 百度飞桨(PaddlePaddle) - PaddleHub OCR 文字识别简单使用. 博客园. 2023.05
汽车人. Pytorch 和 TensorFlow 和 PaddlePaddle 这三个框架有什么区别?. 知乎. 2022.08
https://github.com/PaddlePaddle/PaddleOCR/blob/release/2.7/ppstructure/docs/quickstart.md

附件:文章来源地址https://www.toymoban.com/news/detail-699798.html

Package                   Version
------------------------- -----------
anyio                     4.0.0
argon2-cffi               23.1.0
argon2-cffi-bindings      21.2.0
arrow                     1.2.3
astor                     0.8.1
asttokens                 2.3.0
async-lru                 2.0.4
attrdict                  2.0.1
attrs                     23.1.0
Babel                     2.12.1
backcall                  0.2.0
bce-python-sdk            0.8.90
beautifulsoup4            4.12.2
bleach                    6.0.0
blinker                   1.6.2
cachetools                5.3.1
certifi                   2023.7.22
cffi                      1.15.1
charset-normalizer        3.2.0
click                     8.1.7
colorama                  0.4.6
comm                      0.1.4
contourpy                 1.1.0
cssselect                 1.2.0
cssutils                  2.7.1
cycler                    0.11.0
Cython                    3.0.2
debugpy                   1.6.7.post1
decorator                 5.1.1
defusedxml                0.7.1
dnspython                 2.4.2
et-xmlfile                1.1.0
exceptiongroup            1.1.3
executing                 1.2.0
fastjsonschema            2.18.0
fire                      0.5.0
flask                     2.3.3
flask-babel               3.1.0
fonttools                 4.42.1
fqdn                      1.5.1
future                    0.18.3
h11                       0.14.0
httpcore                  0.17.3
httpx                     0.24.1
idna                      3.4
imageio                   2.31.3
imgaug                    0.4.0
importlib-metadata        6.8.0
importlib-resources       6.0.1
ipykernel                 6.25.1
ipython                   8.12.2
ipython-genutils          0.2.0
ipywidgets                8.1.0
isoduration               20.11.0
itsdangerous              2.1.2
jedi                      0.19.0
Jinja2                    3.1.2
joblib                    1.3.2
json5                     0.9.14
jsonpointer               2.4
jsonschema                4.19.0
jsonschema-specifications 2023.7.1
kiwisolver                1.4.5
lazy-loader               0.3
lmdb                      1.4.1
lxml                      4.9.3
MarkupSafe                2.1.3
matplotlib                3.7.2
matplotlib-inline         0.1.6
mistune                   3.0.1
nbclient                  0.8.0
nbconvert                 7.8.0
nbformat                  5.9.2
nest-asyncio              1.5.7
networkx                  3.1
notebook                  7.0.3
notebook-shim             0.2.3
numpy                     1.24.4
opencv-contrib-python     4.6.0.66
opencv-python             4.6.0.66
openpyxl                  3.1.2
opt-einsum                3.3.0
overrides                 7.4.0
packaging                 23.1
paddle-bfloat             0.1.7
paddleocr                 2.7.0.2
paddlepaddle              2.5.1
pandas                    2.0.3
pandocfilters             1.5.0
parso                     0.8.3
pdf2docx                  0.5.6
pickleshare               0.7.5
Pillow                    10.0.0
pip                       21.1.1
pkgutil-resolve-name      1.3.10
platformdirs              3.10.0
premailer                 3.10.0
prometheus-client         0.17.1
prompt-toolkit            3.0.39
protobuf                  3.20.2
psutil                    5.9.5
pure-eval                 0.2.2
pyclipper                 1.3.0.post4
pycparser                 2.21
pycryptodome              3.18.0
Pygments                  2.16.1
pymongo                   4.5.0
PyMuPDF                   1.20.2
pyparsing                 3.0.9
python-dateutil           2.8.2
python-docx               0.8.11
python-json-logger        2.0.7
pytz                      2023.3
PyWavelets                1.4.1
pywin32                   306
pywinpty                  2.0.11
PyYAML                    6.0.1
pyzmq                     25.1.1
qtconsole                 5.4.4
QtPy                      2.4.0
rapidfuzz                 3.2.0
rarfile                   4.0
referencing               0.30.2
requests                  2.31.0
rfc3339-validator         0.1.4
rfc3986-validator         0.1.1
rpds-py                   0.10.0
scikit-image              0.21.0
scikit-learn              1.3.0
scipy                     1.10.1
Send2Trash                1.8.2
setuptools                56.0.0
Shapely                   1.8.2
six                       1.16.0
sniffio                   1.3.0
soupsieve                 2.5
stack-data                0.6.2
termcolor                 2.3.0
terminado                 0.17.1
threadpoolctl             3.2.0
tifffile                  2023.7.10
tinycss2                  1.2.1
tomli                     2.0.1
tornado                   6.3.3
tqdm                      4.66.1
traitlets                 5.9.0
typing-extensions         4.7.1
tzdata                    2023.3
uri-template              1.3.0
urllib3                   2.0.4
visualdl                  2.5.3
wcwidth                   0.2.6
webcolors                 1.13
webencodings              0.5.1
websocket-client          1.6.2
werkzeug                  2.3.7
widgetsnbextension        4.0.8
zipp                      3.16.2

到了这里,关于百度飞浆OCR识别表格入门python实践的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【Python】【OpenCV】OCR识别(三)——字符识别

    通过上一篇博客,我们成功将有角度的图片进行“摆正”,接下来我们来提取图片中的文字。 我们使用Tesseract来处理图片并提取文字,相关下载安装请参考:Python下Tesseract Ocr引擎及安装介绍 - 黯然销魂掌2015 - 博客园 (cnblogs.com) 同时我们需要下载第三方Lib——pytesseract,使用

    2024年02月02日
    浏览(31)
  • Python实现OCR文字识别

    OCR(Optical Character Recognition,光学字符识别)是指通过扫描纸质文档或照片,通过计算机对图像记录的文字进行识别的一种技术。本文介绍如何使用Python来实现OCR文字识别技术。 要实现Python的OCR文字识别,首先需要安装OCR软件和相关的包依赖,比如pytesseract和OpenCV。 安装pyt

    2024年02月16日
    浏览(27)
  • python之OCR文字识别

    将图片翻译成文字一般被称为光学文字识别(Optical Character Recognition,OCR)。可以实现OCR 的底层库并不多,目前很多库都是使用共同的几个底层OCR 库,或者是在上面进行定制。 easyocr是基于torch的深度学习模块 easyocr安装后调用过程中出现opencv版本不兼容问题,所以放弃此方案

    2024年02月20日
    浏览(27)
  • 【Python】【OpenCV】OCR识别(一)

    接着练手图像处理例子   抛开网上截图进行OCR识别,更多的图源来自于我们的手机,相机等等设备,而得到的图片都并非是板正的,大多随手一拍的图源都是带有角度的,所以我们需要先将图像进行摆正。 首先先对图像进行预处理,上代码:         1、使用Canny来进行边缘

    2024年02月03日
    浏览(28)
  • OCR表格识别(三)——文本检测与文本识别理论学习

    图像识别其实是一个从低层次到高层级特征学习的过程。底层级的特征比较抽象,二高层及的特征比较概念化。在图像识别过程中,也就是从图像像素特征,到图像的形状、轮廓,然后到概念,并进行整合,分类,最终得到目标特征,识别到人脸等。再怎么复杂的信息都是由

    2024年02月05日
    浏览(34)
  • ComPDFKit 转档SDK OCR表格识别功能

    我们非常高兴地宣布,适用于 Windows、iOS、Android 和服务器的 ComPDFKit 转档SDK 1.8.0 现已发布!在该版本中,OCR 功能支持了表格识别,优化了OCR文字识别率。PDF to HTML 优化了html 文件结构,使转换后的 HTML 文件容量大幅减少。 OCR 表格识别: Windows: CPDFConvertWordOptions wordOptions = n

    2024年02月15日
    浏览(25)
  • Python制作简易OCR文字识别系统

    前不久看了一篇“如何使用Python检测和识别车牌?”用OpenCV对输入图像进行预处理,用imutils将原始输入图像裁剪成所需的大小,用pytesseract将提取车牌字符转换成字符串(车牌识别)。 但经实测,美式车牌识别基本正确,但中国92式车牌、新能源车牌识别基本失败,失败的现象

    2024年02月08日
    浏览(33)
  • 【实操】Java+百度ocr,实现图片识别文字小工具

    图片识别文字,咱用java也可以 通过 java+百度ocr ,实现一个截图或上传图片, 图片识别文字的小工具 。并通过 exe4j工具 将jar包封装成exe可执行桌面文件,方便使用及学习。 一位特别的老友即将 在2023年10月26日 年满 30周岁 ,愿 平安喜乐 公众号:【JavaDog程序狗】 关注公众号

    2024年02月08日
    浏览(33)
  • 如何使用Python实现图像文字识别OCR

    要使用Python实现图像文字识别OCR,可以使用以下步骤: 安装Tesseract OCR引擎 Tesseract是一种开源OCR引擎,可以处理多种语言和字体。要使用Python进行OCR,需要安装Tesseract OCR引擎。安装方法可以在Tesseract的官方网站上找到。 安装Python模块 要使用Python进行OCR,需要安装Python模块。

    2024年02月04日
    浏览(30)
  • python ocr(光学文字识别) 学习笔记 (一)

    参考资料:500 lines or less ocr 我们的OCR系统主要由5部分组成,分别写在5个文件之中。它们分别是: 客户端(ocr.js) 服务器(server.py) 简单的用户界面(ocr.html) 基于反向传播训练的ANN(ocr.py) ANN的实现脚本(neural network design.py) 虽然界面服务器用户界面不是我们的重点,但由于笔者水平有

    2024年02月08日
    浏览(27)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包