深度学习系列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)
相关推荐
雨大王5121 分钟前
工业AI大模型在汽车制造中的应用:如何选择最适合的解决方案?
人工智能
AC赳赳老秦4 分钟前
Kubernetes 与 DeepSeek:高效 Pod 部署配置与资源调度优化指南
人工智能·云原生·容器·kubernetes·自动化·notepad++·deepseek
OpenCSG7 分钟前
兼顾开源创新与数据安全:CSGHub 为企业 AI 选型提供最优解
人工智能·开源
AI工具测评大师8 分钟前
如何有效降低英文文本的Turnitin AI检测率?安全指南与工具推荐
人工智能·深度学习·自然语言处理·文心一言·ai写作·ai自动写作
陈天伟教授9 分钟前
人工智能应用-机器视觉:绘画大师 05.还原毕加索的隐藏画
人工智能·神经网络·数码相机·生成对抗网络·dnn
WZGL123011 分钟前
2026中国智慧养老行业:老龄化浪潮下的刚性需求爆发
大数据·人工智能·物联网
橘子师兄12 分钟前
C++AI大模型接入SDK—ChatSDK使用手册
开发语言·c++·人工智能
ZCXZ12385296a13 分钟前
果园喷药除草机器人目标检测:YOLO11-Seg-FasterNet实现喷雾药车遥感药箱识别
人工智能·目标检测·机器人
公链开发14 分钟前
2026链上预测趋势:Prediction Markets + AI融合真实案例与开发路径
人工智能
20130924162715 分钟前
1956年Newell与Simon经典论文逻辑理论家(The Logic Theorist):人工智能符号主义的创世纪
人工智能