深度学习系列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)
相关推荐
MVP-curry-萌神11 分钟前
FPGA图像处理(六)------ 图像腐蚀and图像膨胀
图像处理·人工智能·fpga开发
struggle202528 分钟前
ebook2audiobook开源程序使用动态 AI 模型和语音克隆将电子书转换为带有章节和元数据的有声读物。支持 1,107+ 种语言
人工智能·开源·自动化
深空数字孪生31 分钟前
AI+可视化:数据呈现的未来形态
人工智能·信息可视化
sbc-study37 分钟前
双向Transformer:BERT(Bidirectional Encoder Representations from Transformers)
深度学习·bert·transformer
标贝科技1 小时前
标贝科技:大模型领域数据标注的重要性与标注类型分享
数据库·人工智能
aminghhhh1 小时前
多模态融合【十九】——MRFS: Mutually Reinforcing Image Fusion and Segmentation
人工智能·深度学习·学习·计算机视觉·多模态
格林威1 小时前
Baumer工业相机堡盟工业相机的工业视觉是否可以在室外可以做视觉检测项目
c++·人工智能·数码相机·计算机视觉·视觉检测
陈苏同学1 小时前
MPC控制器从入门到进阶(小车动态避障变道仿真 - Python)
人工智能·python·机器学习·数学建模·机器人·自动驾驶
努力毕业的小土博^_^2 小时前
【深度学习|学习笔记】 Generalized additive model广义可加模型(GAM)详解,附代码
人工智能·笔记·深度学习·神经网络·学习
天上路人2 小时前
采用AI神经网络降噪算法的语言降噪消回音处理芯片NR2049-P
深度学习·神经网络·算法·硬件架构·音视频·实时音视频·可用性测试