Dong Liu
commited on
Commit
·
bf90f62
1
Parent(s):
4056097
Add Chinese readme for DeepDoc (#515)
Browse files### What problem does this PR solve?
Add Chinese explanation for deepdoc
### Type of change
- [ ] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [*] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
- deepdoc/README_zh.md +116 -1
deepdoc/README_zh.md
CHANGED
@@ -1 +1,116 @@
|
|
1 |
-
[English](./README.md) | 简体中文
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[English](./README.md) | 简体中文
|
2 |
+
|
3 |
+
# *Deep*Doc
|
4 |
+
|
5 |
+
- [*Deep*Doc](#deepdoc)
|
6 |
+
- [1. 介绍](#1-介绍)
|
7 |
+
- [2. 视觉处理](#2-视觉处理)
|
8 |
+
- [3. 解析器](#3-解析器)
|
9 |
+
- [简历](#简历)
|
10 |
+
|
11 |
+
<a name="1"></a>
|
12 |
+
## 1. 介绍
|
13 |
+
|
14 |
+
对于来自不同领域、具有不同格式和不同检索要求的大量文档,准确的分析成为一项极具挑战性的任务。*Deep*Doc 就是为了这个目的而诞生的。到目前为止,*Deep*Doc 中有两个组成部分:视觉处理和解析器。如果您对我们的OCR、布局识别和TSR结果感兴趣,您可以运行下面的测试程序。
|
15 |
+
|
16 |
+
```bash
|
17 |
+
python deepdoc/vision/t_ocr.py -h
|
18 |
+
usage: t_ocr.py [-h] --inputs INPUTS [--output_dir OUTPUT_DIR]
|
19 |
+
|
20 |
+
options:
|
21 |
+
-h, --help show this help message and exit
|
22 |
+
--inputs INPUTS Directory where to store images or PDFs, or a file path to a single image or PDF
|
23 |
+
--output_dir OUTPUT_DIR
|
24 |
+
Directory where to store the output images. Default: './ocr_outputs'
|
25 |
+
```
|
26 |
+
|
27 |
+
```bash
|
28 |
+
python deepdoc/vision/t_recognizer.py -h
|
29 |
+
usage: t_recognizer.py [-h] --inputs INPUTS [--output_dir OUTPUT_DIR] [--threshold THRESHOLD] [--mode {layout,tsr}]
|
30 |
+
|
31 |
+
options:
|
32 |
+
-h, --help show this help message and exit
|
33 |
+
--inputs INPUTS Directory where to store images or PDFs, or a file path to a single image or PDF
|
34 |
+
--output_dir OUTPUT_DIR
|
35 |
+
Directory where to store the output images. Default: './layouts_outputs'
|
36 |
+
--threshold THRESHOLD
|
37 |
+
A threshold to filter out detections. Default: 0.5
|
38 |
+
--mode {layout,tsr} Task mode: layout recognition or table structure recognition
|
39 |
+
```
|
40 |
+
|
41 |
+
HuggingFace为我们的模型提供服务。如果你在下载HuggingFace模型时遇到问题,这可能会有所帮助!!
|
42 |
+
|
43 |
+
```bash
|
44 |
+
export HF_ENDPOINT=https://hf-mirror.com
|
45 |
+
```
|
46 |
+
|
47 |
+
<a name="2"></a>
|
48 |
+
## 2. 视觉处理
|
49 |
+
|
50 |
+
作为人类,我们使用视觉信息来解决问题。
|
51 |
+
|
52 |
+
- **OCR(Optical Character Recognition,光学字符识别)**。由于许多文档都是以图像形式呈现的,或者至少能够转换为图像,因此OCR是文本提取的一个非常重要、基本,甚至通用的解决方案。
|
53 |
+
|
54 |
+
```bash
|
55 |
+
python deepdoc/vision/t_ocr.py --inputs=path_to_images_or_pdfs --output_dir=path_to_store_result
|
56 |
+
```
|
57 |
+
|
58 |
+
输入可以是图像或PDF的目录,或者单个图像、PDF文件。您可以查看文件夹 `path_to_store_result` ,其中有演示结果位置的图像,以及包含OCR文本的txt文件。
|
59 |
+
|
60 |
+
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
61 |
+
<img src="https://github.com/infiniflow/ragflow/assets/12318111/f25bee3d-aaf7-4102-baf5-d5208361d110" width="900"/>
|
62 |
+
</div>
|
63 |
+
|
64 |
+
- 布局识别(Layout recognition)。来自不同领域的文件可能有不同的布局,如报纸、杂志、书籍和简历在布局方面是不同的。只有当机器有准确的布局分析时,它才能决定这些文本部分是连续的还是不连续的,或者这个部分需要表结构识别(Table Structure Recognition,TSR)来处理,或者这个部件是一个图形并用这个标题来描述。我们有10个基本布局组件,涵盖了大多数情况:
|
65 |
+
- 文本
|
66 |
+
- 标题
|
67 |
+
- 配图
|
68 |
+
- 配图标题
|
69 |
+
- 表格
|
70 |
+
- 表格标题
|
71 |
+
- 页头
|
72 |
+
- 页尾
|
73 |
+
- 参考引用
|
74 |
+
- 公式
|
75 |
+
|
76 |
+
请尝试以下命令以查看布局检测结果。
|
77 |
+
|
78 |
+
```bash
|
79 |
+
python deepdoc/vision/t_recognizer.py --inputs=path_to_images_or_pdfs --threshold=0.2 --mode=layout --output_dir=path_to_store_result
|
80 |
+
```
|
81 |
+
|
82 |
+
输入可以是图像或PDF的目录,或者单个图像、PDF文件。您可以查看文件夹 `path_to_store_result` ,其中有显示检测结果的图像,如下所示:
|
83 |
+
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
84 |
+
<img src="https://github.com/infiniflow/ragflow/assets/12318111/07e0f625-9b28-43d0-9fbb-5bf586cd286f" width="1000"/>
|
85 |
+
</div>
|
86 |
+
|
87 |
+
- **TSR(Table Structure Recognition,表结构识别)**。数据表是一种常用的结构,用于表示包括数字或文本在内的数据。表的结构可能非常复杂,比如层次结构标题、跨单元格和投影行标题。除了TSR,我们还将内容重新组合成LLM可以很好理解的句子。TSR任务有五个标签:
|
88 |
+
- 列
|
89 |
+
- 行
|
90 |
+
- 列标题
|
91 |
+
- 行标题
|
92 |
+
- 合并单元格
|
93 |
+
|
94 |
+
请尝试以下命令以查看布局检测结果。
|
95 |
+
|
96 |
+
```bash
|
97 |
+
python deepdoc/vision/t_recognizer.py --inputs=path_to_images_or_pdfs --threshold=0.2 --mode=tsr --output_dir=path_to_store_result
|
98 |
+
```
|
99 |
+
|
100 |
+
输入可以是图像或PDF的目录,或者单个图像、PDF文件。您可以查看文件夹 `path_to_store_result` ,其中包含图像和html页面,这些页面展示了以下检测结果:
|
101 |
+
|
102 |
+
<div align="center" style="margin-top:20px;margin-bottom:20px;">
|
103 |
+
<img src="https://github.com/infiniflow/ragflow/assets/12318111/cb24e81b-f2ba-49f3-ac09-883d75606f4c" width="1000"/>
|
104 |
+
</div>
|
105 |
+
|
106 |
+
<a name="3"></a>
|
107 |
+
## 3. 解析器
|
108 |
+
|
109 |
+
PDF、DOCX、EXCEL和PPT四种文档格式都有相应的解析器。最复杂的是PDF解析器,因为PDF具有灵活性。PDF解析器的输出包括:
|
110 |
+
- 在PDF中有自己位置的文本块(页码和矩形位置)。
|
111 |
+
- 带有PDF裁剪图像的表格,以及已经翻译成自然语言句子的内容。
|
112 |
+
- 图中带标题和文字的图。
|
113 |
+
|
114 |
+
### 简历
|
115 |
+
|
116 |
+
简历是一种非常复杂的文件。一份由各种布局的非结构化文本组成的简历可以分解为由近百个字段组成的结构化数据。我们还没有打开解析器,因为我们在解析过程之后打开了处理方法。
|