深度学习系列73:使用rapidStructure进行版面分析

1. 概述

项目地址https://github.com/RapidAI/RapidStructure?tab=readme-ov-file

2. 文档方向分类示例

安装$ pip install rapid-orientation

复制代码
import cv2
from rapid_orientation import RapidOrientation
orientation_engine = RapidOrientation()
img = cv2.imread('test_images/layout.png')
orientation_res, elapse = orientation_engine(img)
print(orientation_res)
# 返回结果为str类型,有四类:0 | 90 | 180 | 270

3. 版面分析RapidLayout

安装$ pip install rapid-layout

复制代码
import cv2
from rapid_layout import RapidLayout, VisLayout

# model_type类型参见上表。指定不同model_type时,会自动下载相应模型到安装目录下的。
layout_engine = RapidLayout(conf_thres=0.5, model_type="pp_layout_cdla")

img = cv2.imread('test_images/layout.png')

boxes, scores, class_names, elapse = layout_engine(img)
ploted_img = VisLayout.draw_detections(img, boxes, scores, class_names)
if ploted_img is not None:
    cv2.imwrite("layout_res.png", ploted_img)

4. 文字识别和表格识别rapid_table

复制代码
from rapid_table import RapidTable, VisTable

# RapidTable类提供model_path参数,可以自行指定上述2个模型,默认是en_ppstructure_mobile_v2_SLANet.onnx
# table_engine = RapidTable(model_path='ch_ppstructure_mobile_v2_SLANet.onnx')
table_engine = RapidTable()
ocr_engine = RapidOCR()
viser = VisTable()

img_path = 'test_images/table.jpg'

ocr_result, _ = ocr_engine(img_path)
table_html_str, table_cell_bboxes, elapse = table_engine(img_path, ocr_result)

5. latex识别rapidLaTexOCR

复制代码
from rapid_latex_ocr import LatexOCR
model = LatexOCR()
img_path = "tests/test_files/6.png"
with open(img_path, "rb") as f:
    data = f.read()
res, elapse = model(data)

6. 整合版:RapidOCRPDF

复制代码
# 基于CPU 依赖rapidocr_onnxruntime
pip install rapidocr_pdf[onnxruntime]
# 基于CPU 依赖rapidocr_openvino 更快
pip install rapidocr_pdf[openvino]
# 基于GPU 依赖rapidocr_paddle
pip install rapidocr_pdf[paddle]

使用:

复制代码
from rapidocr_pdf import PDFExtracter
pdf_extracter = PDFExtracter()
pdf_path = 'tests/test_files/direct_and_image.pdf'
texts = pdf_extracter(pdf_path, force_ocr=False)
print(texts)
相关推荐
澳鹏Appen1 小时前
数据集月度精选 | 高质量具身智能数据集:打开机器人“感知-决策-动作”闭环的钥匙
人工智能·机器人·具身智能
q***71013 小时前
开源模型应用落地-工具使用篇-Spring AI-Function Call(八)
人工智能·spring·开源
极限实验室3 小时前
Coco AI 参选 Gitee 2025 最受欢迎开源软件!您的每一票,都是对中国开源的硬核支持
人工智能·开源
secondyoung3 小时前
Mermaid流程图高效转换为图片方案
c语言·人工智能·windows·vscode·python·docker·流程图
iFlow_AI3 小时前
iFlow CLI Hooks 「从入门到实战」应用指南
开发语言·前端·javascript·人工智能·ai·iflow·iflow cli
Shang180989357263 小时前
THC63LVD1027D一款10位双链路LVDS信号中继器芯片,支持WUXGA分辨率视频数据传输THC63LVD1027支持30位数据通道方案
人工智能·考研·信息与通信·信号处理·thc63lvd1027d·thc63lvd1027
飞哥数智坊3 小时前
项目太大,AI无法理解?试试这3种思路
人工智能·ai编程
桜吹雪4 小时前
手搓一个简易Agent
前端·人工智能·后端
数字时代全景窗4 小时前
从App时代到智能体时代,如何打破“三堵墙”
人工智能·软件工程
weixin_469163694 小时前
金融科技项目管理方式在AI加持下发展方向之,需求分析精准化减少业务与技术偏差
人工智能·科技·金融·项目管理·需求管理