## Rapid Layout
##### 简介和说明
- 该部分主要是做文档类图像的版面分析。
- 具体来说,就是分析给定的文档类别图像(论文截图等),定位其中类别和位置,如标题、段落、表格和图片等各个部分。
- 目前支持三种类别的版面分析模型:中文、英文和表格版面分析模型,具体可参见下面表格:
| 模型类型 | 模型名称 | 模型大小 | 支持种类 |
|:---:|:---:|:---:|:---:|
| 表格 | `layout_table.onnx` | 7.06M | `table` |
| 英文 | `layout_publaynet.onnx` | 7.06M | `text title list table figure` |
| 中文 | `layout_cdla.onnx` | 7.07M | `text title figure figure_caption table table_caption`
`header footer reference equation` |
- 模型下载地址为:[百度网盘](https://pan.baidu.com/s/1PI9fksW6F6kQfJhwUkewWg?pwd=p29g) | [Google Drive](https://drive.google.com/drive/folders/1DAPWSN2zGQ-ED_Pz7RaJGTjfkN2-Mvsf?usp=sharing)
#### 使用方式
1. pip安装
- 由于模型较小,预先将中文版面分析模型(`layout_cdla.onnx`)打包进了whl包内,如果做中文版面分析,可直接安装使用
```bash
$ pip install rapid-layout
```
2. python脚本运行
```python
import cv2
from rapid_layout import RapidLayout
layout_engine = RapidLayout()
img = cv2.imread('test_images/layout.png')
layout_res, elapse = layout_engine(img)
```
3. 终端运行
```bash
# 假设在rapid_structure目录下
$ rapid_layout --img_path test_images/ch.png
```
4. 结果
- 返回结果
```python
# bbox: [左上角x0,左上角y0, 右下角x0, 右上角x1]
# label: 类别
[
{'bbox': array([321.4160495, 91.53214898, 562.06141263, 199.85522603]), 'label': 'text'},
{'bbox': array([58.67292211, 107.29000663, 300.25448676, 199.68142]), 'label': 'table_caption'}
]
```
- 可视化结果