Skip to content

Commit 1538d93

Browse files
authored
Merge pull request #5188 from WenmuZhou/update_whl_dygraph
cp 5186
2 parents ed8c2af + 8375a87 commit 1538d93

File tree

8 files changed

+151
-168
lines changed

8 files changed

+151
-168
lines changed

doc/doc_ch/algorithm_overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ PaddleOCR开源的文本检测算法列表:
2525
在ICDAR2015文本检测公开数据集上,算法效果如下:
2626
|模型|骨干网络|precision|recall|Hmean|下载链接|
2727
| --- | --- | --- | --- | --- | --- |
28-
|EAST|ResNet50_vd|85.80%|86.71%|86.25%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar)|
29-
|EAST|MobileNetV3|79.42%|80.64%|80.03%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
28+
|EAST|ResNet50_vd|88.71%|81.36%|84.88%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar)|
29+
|EAST|MobileNetV3|78.2%|79.1%|78.65%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
3030
|DB|ResNet50_vd|86.41%|78.72%|82.38%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_db_v2.0_train.tar)|
3131
|DB|MobileNetV3|77.29%|73.08%|75.12%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar)|
3232
|SAST|ResNet50_vd|91.39%|83.77%|87.42%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar)|

doc/doc_en/algorithm_overview_en.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ On the ICDAR2015 dataset, the text detection result is as follows:
3030

3131
|Model|Backbone|Precision|Recall|Hmean|Download link|
3232
| --- | --- | --- | --- | --- | --- |
33-
|EAST|ResNet50_vd|85.80%|86.71%|86.25%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar)|
34-
|EAST|MobileNetV3|79.42%|80.64%|80.03%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
33+
|EAST|ResNet50_vd|88.71%|81.36%|84.88%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_east_v2.0_train.tar)|
34+
|EAST|MobileNetV3|78.2%|79.1%|78.65%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
3535
|DB|ResNet50_vd|86.41%|78.72%|82.38%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_db_v2.0_train.tar)|
3636
|DB|MobileNetV3|77.29%|73.08%|75.12%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar)|
3737
|SAST|ResNet50_vd|91.39%|83.77%|87.42%|[trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_r50_vd_sast_icdar15_v2.0_train.tar)|

paddleocr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
]
4343

4444
SUPPORT_DET_MODEL = ['DB']
45-
VERSION = '2.3.0.2'
45+
VERSION = '2.4'
4646
SUPPORT_REC_MODEL = ['CRNN']
4747
BASE_DIR = os.path.expanduser("~/.paddleocr/")
4848

ppstructure/README.md

Lines changed: 77 additions & 124 deletions
Large diffs are not rendered by default.

ppstructure/README_ch.md

Lines changed: 57 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
[English](README.md) | 简体中文
22

3-
## 简介
3+
- [1. 简介](#1)
4+
- [2. 近期更新](#2)
5+
- [3. 特性](#3)
6+
- [4. 效果展示](#4)
7+
* [4.1 版面分析和表格识别](#41)
8+
* [4.2 DOC-VQA](#42)
9+
- [5. 快速体验](#5)
10+
- [6. PP-Structure 介绍](#6)
11+
* [6.1 版面分析+表格识别](#61)
12+
* [6.2 DOC-VQA](#62)
13+
- [7. 模型库](#7)
14+
15+
<a name="1"></a>
16+
17+
## 1. 简介
418
PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包,旨在帮助开发者更好的完成文档理解相关任务。
519

6-
## 近期更新
7-
* 2021.12.07 新增VQA任务-SER和RE。
20+
<a name="2"></a>
821

9-
## 特性
22+
## 2. 近期更新
23+
* 2021.12.07 新增DOC-[VQA任务SER和RE](vqa/README.md)
1024

11-
PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包,主要特性如下:
25+
<a name="3"></a>
26+
27+
## 3. 特性
28+
29+
PP-Structure的主要特性如下:
1230
- 支持对图片形式的文档进行版面分析,可以划分**文字、标题、表格、图片以及列表**5类区域(与Layout-Parser联合使用)
1331
- 支持文字、标题、图片以及列表区域提取为文字字段(与PP-OCR联合使用)
1432
- 支持表格区域进行结构化分析,最终结果输出Excel文件
@@ -17,13 +35,22 @@ PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包
1735
- 支持文档视觉问答(Document Visual Question Answering,DOC-VQA)任务-语义实体识别(Semantic Entity Recognition,SER)和关系抽取(Relation Extraction,RE)
1836

1937

20-
## 1. 效果展示
38+
<a name="4"></a>
39+
40+
## 4. 效果展示
2141

22-
### 1.1 版面分析和表格识别
42+
<a name="41"></a>
43+
44+
### 4.1 版面分析和表格识别
2345

2446
<img src="../doc/table/ppstructure.GIF" width="100%"/>
2547

26-
### 1.2 VQA
48+
图中展示了版面分析+表格识别的整体流程,图片先有版面分析划分为图像、文本、标题和表格四种区域,然后对图像、文本和标题三种区域进行OCR的检测识别,对表格进行表格识别,其中图像还会被存储下来以便使用。
49+
50+
51+
<a name="42"></a>
52+
53+
### 4.2 DOC-VQA
2754

2855
* SER
2956

@@ -46,36 +73,45 @@ PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包
4673

4774
图中红色框表示问题,蓝色框表示答案,问题和答案之间使用绿色线连接。在OCR检测框的左上方也标出了对应的类别和OCR识别结果。
4875

49-
## 2. 快速体验
76+
<a name="5"></a>
77+
78+
## 5. 快速体验
79+
80+
请参考[快速安装](./docs/quickstart.md)教程。
5081

51-
代码体验:从 [快速安装](./docs/quickstart.md) 开始
82+
<a name="6"></a>
5283

53-
## 3. PP-Structure Pipeline介绍
84+
## 6. PP-Structure 介绍
5485

55-
### 3.1 版面分析+表格识别
86+
<a name="61"></a>
87+
88+
### 6.1 版面分析+表格识别
5689

5790
![pipeline](../doc/table/pipeline.jpg)
5891

5992
在PP-Structure中,图片会先经由Layout-Parser进行版面分析,在版面分析中,会对图片里的区域进行分类,包括**文字、标题、图片、列表和表格**5类。对于前4类区域,直接使用PP-OCR完成对应区域文字检测与识别。对于表格类区域,经过表格结构化处理后,表格图片转换为相同表格样式的Excel文件。
6093

61-
#### 3.1.1 版面分析
94+
#### 6.1.1 版面分析
6295

6396
版面分析对文档数据进行区域分类,其中包括版面分析工具的Python脚本使用、提取指定类别检测框、性能指标以及自定义训练版面分析模型,详细内容可以参考[文档](layout/README_ch.md)
6497

65-
#### 3.1.2 表格识别
98+
#### 6.1.2 表格识别
99+
100+
表格识别将表格图片转换为excel文档,其中包含对于表格文本的检测和识别以及对于表格结构和单元格坐标的预测,详细说明参考[文档](table/README_ch.md)
66101

67-
表格识别将表格图片转换为excel文档,其中包含对于表格文本的检测和识别以及对于表格结构和单元格坐标的预测,详细说明参考[文档](table/README_ch.md)
102+
<a name="62"></a>
68103

104+
### 6.2 DOC-VQA
69105

70-
### 3.2 VQA
106+
DOC-VQA指文档视觉问答,其中包括语义实体识别 (Semantic Entity Recognition, SER) 和关系抽取 (Relation Extraction, RE) 任务。基于 SER 任务,可以完成对图像中的文本识别与分类;基于 RE 任务,可以完成对图象中的文本内容的关系提取,如判断问题对(pair),详细说明参考[文档](vqa/README.md)
71107

72-
coming soon
108+
<a name="7"></a>
73109

74-
## 4. 模型库
110+
## 7. 模型库
75111

76112
PP-Structure系列模型列表(更新中)
77113

78-
* LayoutParser 模型
114+
* 版面分析模型
79115

80116
|模型名称|模型简介|下载地址|
81117
| --- | --- | --- |
@@ -90,12 +126,12 @@ PP-Structure系列模型列表(更新中)
90126
|ch_ppocr_mobile_slim_v2.0_rec|slim裁剪量化版超轻量模型,支持中英文、数字识别|6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_slim_train.tar) |
91127
|en_ppocr_mobile_v2.0_table_structure|PubLayNet数据集训练的英文表格场景的表格结构预测|18.6M|[推理模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar) |
92128

93-
* VQA模型
129+
* DOC-VQA 模型
94130

95131
|模型名称|模型简介|模型大小|下载地址|
96132
| --- | --- | --- | --- |
97133
|PP-Layout_v1.0_ser_pretrained|基于LayoutXLM在xfun中文数据集上训练的SER模型|1.4G|[推理模型 coming soon]() / [训练模型](https://paddleocr.bj.bcebos.com/pplayout/PP-Layout_v1.0_ser_pretrained.tar) |
98134
|PP-Layout_v1.0_re_pretrained|基于LayoutXLM在xfun中文数据集上训练的RE模型|1.4G|[推理模型 coming soon]() / [训练模型](https://paddleocr.bj.bcebos.com/pplayout/PP-Layout_v1.0_re_pretrained.tar) |
99135

100136

101-
更多模型下载,可以参考 [模型库](./docs/model_list.md)
137+
更多模型下载,可以参考 [PPOCR model_list](../doc/doc_en/models_list.md) and [PPStructure model_list](./docs/model_list.md)

ppstructure/predict_system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from ppocr.utils.logging import get_logger
3131
from tools.infer.predict_system import TextSystem
3232
from ppstructure.table.predict_table import TableSystem, to_excel
33-
from ppstructure.vqa.infer_ser_e2e import SerPredictor, draw_ser_results
3433
from ppstructure.utility import parse_args, draw_structure_result
3534

3635
logger = get_logger()
@@ -66,6 +65,7 @@ def __init__(self, args):
6665
self.use_angle_cls = args.use_angle_cls
6766
self.drop_score = args.drop_score
6867
elif self.mode == 'vqa':
68+
from ppstructure.vqa.infer_ser_e2e import SerPredictor, draw_ser_results
6969
self.vqa_engine = SerPredictor(args)
7070

7171
def __call__(self, img):

ppstructure/vqa/README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ PP-Structure 里的 DOC-VQA算法基于PaddleNLP自然语言处理算法库进
6262
- **(1) 安装PaddlePaddle**
6363

6464
```bash
65-
pip3 install --upgrade pip
65+
python3 -m pip install --upgrade pip
6666

6767
# GPU安装
6868
python3 -m pip install paddlepaddle-gpu==2.2 -i https://mirror.baidu.com/pypi/simple
@@ -79,7 +79,7 @@ python3 -m pip install paddlepaddle==2.2 -i https://mirror.baidu.com/pypi/simple
7979
- **(1)pip快速安装PaddleOCR whl包(仅预测)**
8080

8181
```bash
82-
pip install paddleocr
82+
python3 -m pip install paddleocr
8383
```
8484

8585
- **(2)下载VQA源码(预测+训练)**
@@ -93,18 +93,11 @@ git clone https://gitee.com/paddlepaddle/PaddleOCR
9393
# 注:码云托管代码可能无法实时同步本github项目更新,存在3~5天延时,请优先使用推荐方式。
9494
```
9595

96-
- **(3)安装PaddleNLP**
97-
98-
```bash
99-
pip3 install "paddlenlp>=2.2.1"
100-
```
101-
102-
10396
- **(4)安装VQA的`requirements`**
10497

10598
```bash
10699
cd ppstructure/vqa
107-
pip install -r requirements.txt
100+
python3 -m pip install -r requirements.txt
108101
```
109102

110103
## 4. 使用
@@ -131,7 +124,7 @@ wget https://paddleocr.bj.bcebos.com/dataset/XFUND.tar
131124
* 启动训练
132125

133126
```shell
134-
python3.7 train_ser.py \
127+
python3 train_ser.py \
135128
--model_name_or_path "layoutxlm-base-uncased" \
136129
--ser_model_type "LayoutXLM" \
137130
--train_data_dir "XFUND/zh_train/image" \
@@ -152,7 +145,7 @@ python3.7 train_ser.py \
152145
* 恢复训练
153146

154147
```shell
155-
python3.7 train_ser.py \
148+
python3 train_ser.py \
156149
--model_name_or_path "model_path" \
157150
--ser_model_type "LayoutXLM" \
158151
--train_data_dir "XFUND/zh_train/image" \
@@ -189,7 +182,7 @@ python3 eval_ser.py \
189182

190183
```shell
191184
export CUDA_VISIBLE_DEVICES=0
192-
python3.7 infer_ser.py \
185+
python3 infer_ser.py \
193186
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
194187
--ser_model_type "LayoutXLM" \
195188
--output_dir "output/ser/" \
@@ -203,7 +196,7 @@ python3.7 infer_ser.py \
203196

204197
```shell
205198
export CUDA_VISIBLE_DEVICES=0
206-
python3.7 infer_ser_e2e.py \
199+
python3 infer_ser_e2e.py \
207200
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
208201
--ser_model_type "LayoutXLM" \
209202
--max_seq_length 512 \
@@ -215,7 +208,7 @@ python3.7 infer_ser_e2e.py \
215208

216209
```shell
217210
export CUDA_VISIBLE_DEVICES=0
218-
python3.7 helper/eval_with_label_end2end.py --gt_json_path XFUND/zh_val/xfun_normalize_val.json --pred_json_path output_res/infer_results.txt
211+
python3 helper/eval_with_label_end2end.py --gt_json_path XFUND/zh_val/xfun_normalize_val.json --pred_json_path output_res/infer_results.txt
219212
```
220213

221214

@@ -310,7 +303,7 @@ python3 infer_re.py \
310303

311304
```shell
312305
export CUDA_VISIBLE_DEVICES=0
313-
python3.7 infer_ser_re_e2e.py \
306+
python3 infer_ser_re_e2e.py \
314307
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
315308
--re_model_name_or_path "PP-Layout_v1.0_re_pretrained/" \
316309
--ser_model_type "LayoutXLM" \

ppstructure/vqa/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
sentencepiece
22
yacs
3-
seqeval
3+
seqeval
4+
paddlenlp>=2.2.1

0 commit comments

Comments
 (0)