Skip to content

Commit d9dbac7

Browse files
authored
fix: fixed issue #59
1 parent c2b57f4 commit d9dbac7

5 files changed

Lines changed: 21 additions & 23 deletions

File tree

docs/blog/posts/support_pp_doc_layout.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ categories:
99
comments: true
1010
---
1111

12-
本篇文章主要记录如何集成PP-DocLayoutV2/V3模型的
12+
本篇文章主要记录如何集成 PP-DocLayoutV2/V3 模型的
1313

1414
<!-- more -->
1515

1616
### 引言
1717

18-
PP-DocLayout系列模型在版面分析方面效果很好,目前已经作为PaddleOCR-VL系列模型的前置,起着至关重要的作用。
18+
PP-DocLayout 系列模型在版面分析方面效果很好,目前已经作为 PaddleOCR-VL 系列模型的前置,起着至关重要的作用。
1919

20-
文档智能的关键地方就在于此。因此,想着将该模型纳入RapidLayout系列模型中,方便小伙伴们快速使用。
20+
文档智能的关键地方就在于此。因此,想着将该模型纳入 RapidLayout 系列模型中,方便小伙伴们快速使用。
2121

2222
### 运行环境
2323

24-
- 操作系统: Ubuntu
25-
- Python: 3.10.14
24+
- 操作系统:Ubuntu
25+
- Python:3.10.14
2626
- 其他依赖环境:
2727

2828
```text linenums="1"
@@ -40,11 +40,11 @@ paddle2onnx --model_dir=models/PP-DocLayoutV2 --model_filename inference.json
4040

4141
### 比较结果
4242

43-
我在`/xxxx/miniforge3/envs/wjh_debug/lib/python3.10/site-packages/paddlex/inference/models/layout_analysis/predictor.py`中插入以下代码(在 **L103** 行左右),来保证输入相同,比较输出。
43+
我在 `/xxxx/miniforge3/envs/wjh_debug/lib/python3.10/site-packages/paddlex/inference/models/layout_analysis/predictor.py` 中插入以下代码(在 **L103** 行左右),来保证输入相同,比较输出。
4444

4545
#### PP-DocLayoutV2
4646

47-
按照上面直接转换后,在相同输入下,ONNX模型和Paddle模型推理结果误差为 **14.8%** 。在我看来,这个误差其实挺大的。
47+
⚠️注意:按照上面直接转换后,在相同输入下,ONNX 模型和 Paddle 模型推理结果误差为 **14.8%**。在我看来,这个误差其实挺大的。
4848

4949
但是从可视化示例图结果来看,两者并无明显区别。可能在某些图上会有较大区别。
5050

@@ -105,7 +105,7 @@ Max relative difference: 194.
105105
[2.200000e+01, 9.888635e-01, 3.372382e+01, ..., 8.526024e+02,...
106106
```
107107
108-
暂时先用这个ONNX模型,该问题已经反馈到了Paddle2ONNX issue [#1608](https://github.com/PaddlePaddle/Paddle2ONNX/issues/1608#issuecomment-3875561303)
108+
暂时先用这个 ONNX 模型,该问题已经反馈到了 Paddle2ONNX issue [#1608](https://github.com/PaddlePaddle/Paddle2ONNX/issues/1608#issuecomment-3875561303)
109109
110110
#### PP-DocLayoutV3
111111
@@ -128,9 +128,9 @@ Max relative difference among violations: 0.01754386
128128
129129
### 剥离推理代码
130130
131-
因为PaddleOCR库中需要兼容的推理代码较多,大而全。这也导致了有些臃肿。这是难以避免的。但是如果只看PP-DocLayout推理代码的话,很多问题就很简单了。
131+
因为 PaddleOCR 库中需要兼容的推理代码较多,大而全。这也导致了有些臃肿。这是难以避免的。但是如果只看 PP-DocLayout 推理代码的话,很多问题就很简单了。
132132
133-
完整的推理代码,我放到了Gist上 → [link](https://gist.github.com/SWHL/c9455e8947f4abdfbbd8439c0bb83410)
133+
完整的推理代码,我放到了 Gist 上 → [link](https://gist.github.com/SWHL/c9455e8947f4abdfbbd8439c0bb83410)
134134
135135
### 字典写入 ONNX
136136
@@ -216,7 +216,7 @@ t = ONNXMetaOp.get_meta(new_model_path, key="character")
216216
print(t)
217217
```
218218
219-
输出以下`label`,则认为成功:
219+
输出以下 `label`,则认为成功:
220220
221221
```bash linenums="1"
222222
$ python write_dict.py
@@ -227,7 +227,7 @@ PP-DocLayoutV2 和 PP-DocLayoutV3 字典是一样的。
227227
228228
### 使用
229229
230-
目前 PP-DocLayoutV2 在`rapid_layout>=1.1.0`已经支持。PP-DocLayoutV3 在`rapid_layout>=1.2.0`中支持。使用示例:
230+
目前 PP-DocLayoutV2 在 `rapid_layout>=1.1.0` 已经支持。PP-DocLayoutV3 在 `rapid_layout>=1.2.0` 中支持。使用示例:
231231
232232
```python linenums="1"
233233
from rapid_layout import EngineType, ModelType, RapidLayout

docs/contributing.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pip install -e .
5858

5959
## 三、安装代码格式化与 pre-commit 钩子
6060

61-
在已激活的虚拟环境中安装 pre-commit,并在**仓库根目录**启用 Git 提交前钩子,以便自动做代码格式检查与整理(如 blackautoflake 等):
61+
在已激活的虚拟环境中安装 pre-commit,并在 **仓库根目录** 启用 Git 提交前钩子,以便自动做代码格式检查与整理(如 black, autoflake 等):
6262

6363
```bash
6464
pip install pre-commit
@@ -75,7 +75,7 @@ pre-commit run --all-files
7575

7676
## 四、运行单元测试
7777

78-
**仓库根目录**下执行:
78+
**仓库根目录** 下执行:
7979

8080
```bash
8181
# 运行全部测试
@@ -150,7 +150,7 @@ def test_your_new_feature():
150150

151151
## 七、运行所有单元测试
152152

153-
**仓库根目录**下再次全量跑测,确保无回归:
153+
**仓库根目录** 下再次全量跑测,确保无回归:
154154

155155
```bash
156156
pytest tests/ -v
@@ -207,7 +207,7 @@ git push myfork fix/xxx
207207
| `style` | 代码格式(不影响逻辑) |
208208
| `refactor` | 重构 |
209209
| `test` | 测试相关 |
210-
| `chore` | 构建/工具等 |
210+
| `chore` | 构建 / 工具等 |
211211

212212
示例:`fix: 修复某条件下版面结果为空``feat: 支持 xxx 输入格式``docs: 更新安装说明`
213213

@@ -235,7 +235,7 @@ git push myfork fix/xxx
235235
| 3 | 安装 pre-commit(`pip install pre-commit`),在仓库根目录执行 `pre-commit install` |
236236
| 4 | 运行单元测试(`pytest tests/ -v`),确认基线通过 |
237237
| 5 | 复现问题或实现新功能 |
238-
| 6 | 编写/补充对应单元测试 |
238+
| 6 | 编写 / 补充对应单元测试 |
239239
| 7 | 在仓库根目录运行全部测试并确认通过 |
240240
| 8 | Fork 主仓库到个人账号 |
241241
| 9 | 按约定式提交规范编写 commit,将修改提交并推送到个人 Fork 的对应分支 |

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ hide:
2626

2727
### TODO
2828

29-
- [ ] [PP-DocLayout](https://github.com/PaddlePaddle/PaddleX/blob/release/3.0-rc/docs/module_usage/tutorials/ocr_modules/layout_detection.md)整理
29+
- [ ] [PP-DocLayout](https://github.com/PaddlePaddle/PaddleX/blob/release/3.0-rc/docs/module_usage/tutorials/ocr_modules/layout_detection.md) 整理

docs/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ hide:
4646

4747
## 模型下载
4848

49-
模型均已经托管在[魔搭平台](https://www.modelscope.cn/models/RapidAI/RapidLayout/files)
49+
模型均已经托管在 [魔搭平台](https://www.modelscope.cn/models/RapidAI/RapidLayout/files)

rapid_layout/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from .inference_engine.base import get_engine
1212
from .model_handler import ModelHandler, ModelProcessor
13-
from .utils.load_image import LoadImage
13+
from .utils.load_image import InputType, LoadImage
1414
from .utils.typings import ModelType, RapidLayoutInput, RapidLayoutOutput
1515
from .utils.utils import is_url
1616

@@ -43,9 +43,7 @@ def __init__(self, cfg: Optional[RapidLayoutInput] = None, **kwargs):
4343

4444
self.load_img = LoadImage()
4545

46-
def __call__(
47-
self, img_content: Union[str, np.ndarray, bytes, Path]
48-
) -> RapidLayoutOutput:
46+
def __call__(self, img_content: InputType) -> RapidLayoutOutput:
4947
img = self.load_img(img_content)
5048
result = self.model_handler(img)
5149
return result

0 commit comments

Comments
 (0)