11<div align =" center " >
2- <div align =" center " >
3- <h1><b>📖 Rapid Layout</b></h1>
4- </div >
2+ <h1 ><b >📖 Rapid Layout</b ></h1 >
3+ <div >  ; </div >
4+ <b ><font size =" 4 " ><i >文档版面分析 - 定位标题、段落、表格与图片等版面元素</i ></font ></b >
5+ <div >  ; </div >
56
67<a href =" https://huggingface.co/spaces/RapidAI/RapidLayoutv1 " target =" _blank " ><img src =" https://img.shields.io/badge/%F0%9F%A4%97-Hugging Face Demo-blue " ></a >
78<a href =" " ><img src =" https://img.shields.io/badge/Python->=3.6-aff.svg " ></a >
1011<a href =" https://pepy.tech/project/rapid-layout " ><img src =" https://static.pepy.tech/personalized-badge/rapid-layout?period=total&units=abbreviation&left_color=grey&right_color=blue&left_text=Downloads " ></a >
1112<a href =" https://semver.org/ " ><img alt =" SemVer2.0 " src =" https://img.shields.io/badge/SemVer-2.0-brightgreen " ></a >
1213<a href =" https://github.com/psf/black " ><img src =" https://img.shields.io/badge/code%20style-black-000000.svg " ></a >
13- </div >
14-
15- ### 简介
16-
17- 该项目主要是汇集全网开源的版面分析的项目,具体来说,就是分析给定的文档类别图像(论文截图、研报等),定位其中类别和位置,如标题、段落、表格和图片等各个部分。
18-
19- > [ !WARNING]
20- > 由于不同场景下的版面差异较大,现阶段不存在一个模型可以搞定所有场景。如果实际业务需要,以下模型效果不好的话,建议构建自己的训练集微调。
21-
22- 目前支持已经支持的版面分析模型如下:
23-
24- | ` model_type ` | 版面类型 | 支持类别|
25- | :------ | :----- | :----- |
26- | ` pp_layout_table ` | 表格 | ` ["table"] ` |
27- | ` pp_layout_publaynet ` | 英文 | ` ["text", "title", "list", "table", "figure"] ` |
28- | ` pp_layout_cdla ` | 中文 | ` ['text', 'title', 'figure', 'figure_caption', 'table', 'table_caption', 'header', 'footer', 'reference', 'equation'] ` |
29- | ` yolov8n_layout_paper ` | 论文 | ` ['Text', 'Title', 'Header', 'Footer', 'Figure', 'Table', 'Toc', 'Figure caption', 'Table caption'] ` |
30- | ` yolov8n_layout_report ` | 研报 | ` ['Text', 'Title', 'Header', 'Footer', 'Figure', 'Table', 'Toc', 'Figure caption', 'Table caption'] ` |
31- | ` yolov8n_layout_publaynet ` | 英文 | ` ["Text", "Title", "List", "Table", "Figure"] ` |
32- | ` yolov8n_layout_general6 ` | 通用 | ` ["Text", "Title", "Figure", "Table", "Caption", "Equation"] ` |
33- | 🔥` doclayout_docstructbench ` | 通用 | ` ['title', 'plain text', 'abandon', 'figure', 'figure_caption', 'table', 'table_caption', 'table_footnote', 'isolate_formula', 'formula_caption'] ` |
34- | 🔥` doclayout_d4la ` | 通用 | ` ['DocTitle', 'ParaTitle', 'ParaText', 'ListText', 'RegionTitle', 'Date', 'LetterHead', 'LetterDear', 'LetterSign', 'Question', 'OtherText', 'RegionKV', 'RegionList', 'Abstract', 'Author', 'TableName', 'Table', 'Figure', 'FigureName', 'Equation', 'Reference', 'Footer', 'PageHeader', 'PageFooter', 'Number', 'Catalog', 'PageNumber'] ` |
35- | 🔥` doclayout_docsynth ` | 通用 | ` ['Caption', 'Footnote', 'Formula', 'List-item', 'Page-footer', 'Page-header', 'Picture', 'Section-header', 'Table', 'Text', 'Title'] ` |
3614
37- PP模型来源: [ PaddleOCR 版面分析 ] ( https://github.com/PaddlePaddle/PaddleOCR/blob/133d67f27dc8a241d6b2e30a9f047a0fb75bebbe/ppstructure/layout/README_ch.md )
15+ </ div >
3816
39- yolov8n系列来源: [ 360LayoutAnalysis ] ( https://github.com/360AILAB-NLP/360LayoutAnalysis )
17+ ### 📝 简介
4018
41- (推荐使用)🔥doclayout_yolo模型来源: [ DocLayout-YOLO ] ( https://github.com/opendatalab/DocLayout-YOLO ) ,该模型是目前最为优秀的开源模型,挑选了3个基于不同训练集训练得到的模型。其中 ` doclayout_docstructbench ` 来自 [ link ] ( https://huggingface.co/juliozhao/DocLayout-YOLO-DocStructBench/tree/main ) , ` doclayout_d4la ` 来自 [ link ] ( https://huggingface.co/juliozhao/DocLayout-YOLO-D4LA-Docsynth300K_pretrained/blob/main/doclayout_yolo_d4la_imgsz1600_docsynth_pretrain.pt ) , ` doclayout_docsynth ` 来自 [ link ] ( https://huggingface.co/juliozhao/DocLayout-YOLO-DocLayNet-Docsynth300K_pretrained/tree/main ) 。
19+ Rapid Layout 汇集全网开源的版面分析能力,对文档类图像(论文截图、研报等)进行分析,定位其中的 ** 类别与位置 ** ,如标题、段落、表格、图片等版面元素 。
4220
43- 上述模型下载地址为: [ link ] ( https://github.com/RapidAI/ RapidLayout/releases/tag/v0.0.0 )
21+ ** 支持场景概览: ** 支持表格、中文、英文、论文、研报及通用版面等多种类型,内置 PP 系列、YOLOv8 系列以及推荐的 DocLayout-YOLO 等模型。不同场景版面差异较大,暂无单一模型覆盖所有场景;若业务效果不佳,建议自建训练集微调。完整模型列表与下载见 [ 文档站 ] ( https://rapidai. github.io/ RapidLayout/ ) 。
4422
45- ### TODO
23+ 如果您觉得本仓库对您有帮助,欢迎给个 ⭐ 支持一下。
4624
47- - [ ] [ PP-DocLayout ] ( https://github.com/PaddlePaddle/PaddleX/blob/release/3.0-rc/docs/module_usage/tutorials/ocr_modules/layout_detection.md ) 整理
25+ ### 🎥 效果展示
4826
49- ### 安装
27+ <div align =" center " >
28+ <img src="https://github.com/RapidAI/RapidLayout/releases/download/v0.0.0/layout_vis.jpg" width="40%">
29+ </div >
5030
51- 由于模型较小,预先将中文版面分析模型( ` layout_cdla.onnx ` )打包进了whl包内,如果做中文版面分析,可直接安装使用
31+ ### 🛠️ 安装
5232
5333``` bash
5434pip install rapid-layout onnxruntime
5535```
5636
57- ### 使用方式
58-
59- #### python脚本运行
37+ ### 📋 使用
6038
6139``` python
62- from rapid_layout import EngineType, ModelType, RapidLayout, RapidLayoutInput
40+ from rapid_layout import RapidLayout, RapidLayoutInput
6341
6442cfg = RapidLayoutInput()
6543layout_engine = RapidLayout(cfg = cfg)
@@ -71,79 +49,49 @@ print(results)
7149results.vis(" layout_res.png" )
7250```
7351
74- ### 可视化结果
52+ 终端运行: ` rapid_layout test_images/layout.png `
7553
76- <div align =" center " >
77- <img src="https://github.com/RapidAI/RapidLayout/releases/download/v0.0.0/layout_vis.jpg" width="80%">
78- </div >
54+ ### 📚 文档
7955
80- #### 终端运行
56+ 完整文档(安装、使用方式、模型列表、GPU/NPU 配置、参考项目等)请移步: [ ** Rapid Layout 文档 ** ] ( https://rapidai.github.io/RapidLayout/ )
8157
82- ``` bash
83- rapid_layout test_images/layout.png
84- ```
58+ ### 🙏 致谢
8559
86- ### GPU推理
60+ - [ DocLayout-YOLO] ( https://github.com/opendatalab/DocLayout-YOLO )
61+ - [ PaddleOCR 版面分析] ( https://github.com/PaddlePaddle/PaddleOCR/blob/133d67f27dc8a241d6b2e30a9f047a0fb75bebbe/ppstructure/layout/README_ch.md )
62+ - [ 360LayoutAnalysis] ( https://github.com/360AILAB-NLP/360LayoutAnalysis )
63+ - [ ONNX-YOLOv8-Object-Detection] ( https://github.com/ibaiGorordo/ONNX-YOLOv8-Object-Detection )
64+ - [ ChineseDocumentPDF] ( https://github.com/SWHL/ChineseDocumentPDF )
8765
88- - 因为版面分析模型输入图像尺寸固定,故可使用` onnxruntime-gpu ` 来提速。
89- - 因为` rapid_layout ` 库默认依赖是CPU版` onnxruntime ` ,如果想要使用GPU推理,需要手动安装` onnxruntime-gpu ` 。
90- - 详细使用和评测可参见[ AI Studio] ( https://aistudio.baidu.com/projectdetail/8094594 )
66+ ### 🤝 贡献指南
9167
92- #### 安装
68+ 欢迎通过 Issue 反馈问题与建议,或通过 Pull Request 参与代码与文档贡献。完整流程请参阅: [ 贡献指南 ] ( https://rapidai.github.io/RapidLayout/contributing/ ) 。
9369
94- ``` bash
95- pip install rapid_layout
96- pip uninstall onnxruntime
70+ ### 🎖 贡献者
9771
98- # 这里一定要确定onnxruntime-gpu与GPU对应
99- # 可参见https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements
100- pip install onnxruntime-gpu
101- ```
72+ <p align =" left " >
73+ <a href =" https://github.com/RapidAI/RapidLayout/graphs/contributors " >
74+ <img src="https://contrib.rocks/image?repo=RapidAI/RapidLayout&max=400&columns=10" width="60%"/>
75+ </a >
76+ </p >
10277
103- #### 使用
78+ ### 📜 引用
10479
105- ``` python
106- from rapid_layout import EngineType, ModelType, RapidLayout, RapidLayoutInput
80+ 若该项目对您的研究有帮助,可考虑引用:
10781
108- cfg = RapidLayoutInput(
109- model_type = ModelType.PP_LAYOUT_CDLA ,
110- engine_type = EngineType.ONNXRUNTIME ,
111- engine_cfg = {" use_cuda" : True , " cuda_ep_cfg.gpu_id" : 1 },
112- )
113- layout_engine = RapidLayout(cfg = cfg)
114-
115- img_path = " https://raw.githubusercontent.com/RapidAI/RapidLayout/718b60e927ab893c2fad67c98f753b2105a6f421/tests/test_files/layout.jpg"
116- results = layout_engine(img_path)
117- print (results)
118-
119- results.vis(" layout_res.png" )
82+ ``` bibtex
83+ @misc{RapidLayout,
84+ title={{Rapid Layout}: Document Layout Analysis},
85+ author={RapidAI Team},
86+ howpublished = {\url{https://github.com/RapidAI/RapidLayout}},
87+ year={2024}
88+ }
12089```
12190
122- ### NPU使用
91+ ### ⭐️ Star history
12392
124- 详细配置参数参见: [ link ] ( https://github.com /RapidAI/RapidLayout/blob/a7ab63ff291bd72e1a98ac2bb11860575514f432/rapid_layout/configs/engine_cfg.yaml )
93+ [ ![ Stargazers over time ] ( https://starchart.cc /RapidAI/RapidLayout.svg?variant=adaptive )] ( https://starchart.cc/RapidAI/RapidLayout )
12594
126- ``` python
127- from rapid_layout import EngineType, ModelType, RapidLayout, RapidLayoutInput
128-
129- cfg = RapidLayoutInput(
130- model_type = ModelType.PP_LAYOUT_CDLA ,
131- engine_type = EngineType.ONNXRUNTIME ,
132- engine_cfg = {" use_cann" : True , " cann_ep_cfg.gpu_id" : 0 },
133- )
134- layout_engine = RapidLayout(cfg = cfg)
95+ ### ⚖️ 开源许可证
13596
136- img_path = " https://raw.githubusercontent.com/RapidAI/RapidLayout/718b60e927ab893c2fad67c98f753b2105a6f421/tests/test_files/layout.jpg"
137- results = layout_engine(img_path)
138- print (results)
139-
140- results.vis(" layout_res.png" )
141- ```
142-
143- ### 参考项目
144-
145- - [ DocLayout-YOLO] ( https://github.com/opendatalab/DocLayout-YOLO )
146- - [ PP-Structure] ( https://github.com/PaddlePaddle/PaddleOCR/blob/133d67f27dc8a241d6b2e30a9f047a0fb75bebbe/ppstructure/layout/README_ch.md )
147- - [ 360LayoutAnalysis] ( https://github.com/360AILAB-NLP/360LayoutAnalysis )
148- - [ ONNX-YOLOv8-Object-Detection] ( https://github.com/ibaiGorordo/ONNX-YOLOv8-Object-Detection )
149- - [ ChineseDocumentPDF] ( https://github.com/SWHL/ChineseDocumentPDF )
97+ 本项目采用 [ Apache 2.0 license] ( LICENSE ) 开源许可证。
0 commit comments