Skip to content

Commit

Permalink
update whl to 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
WenmuZhou committed Jan 6, 2022
1 parent 56f426f commit 5e49f80
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 42 deletions.
4 changes: 2 additions & 2 deletions doc/doc_ch/algorithm_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ PaddleOCR开源的文本检测算法列表:
在ICDAR2015文本检测公开数据集上,算法效果如下:
|模型|骨干网络|precision|recall|Hmean|下载链接|
| --- | --- | --- | --- | --- | --- |
|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)|
|EAST|MobileNetV3|79.42%|80.64%|80.03%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
|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)|
|EAST|MobileNetV3|78.2%|79.1%|78.65%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_east_v2.0_train.tar)|
|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)|
|DB|MobileNetV3|77.29%|73.08%|75.12%|[训练模型](https://paddleocr.bj.bcebos.com/dygraph_v2.0/en/det_mv3_db_v2.0_train.tar)|
|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)|
Expand Down
4 changes: 2 additions & 2 deletions doc/doc_en/algorithm_overview_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ On the ICDAR2015 dataset, the text detection result is as follows:

|Model|Backbone|Precision|Recall|Hmean|Download link|
| --- | --- | --- | --- | --- | --- |
|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)|
|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)|
|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)|
|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)|
|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)|
|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)|
|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)|
Expand Down
2 changes: 1 addition & 1 deletion paddleocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]

SUPPORT_DET_MODEL = ['DB']
VERSION = '2.3.0.2'
VERSION = '2.4'
SUPPORT_REC_MODEL = ['CRNN']
BASE_DIR = os.path.expanduser("~/.paddleocr/")

Expand Down
60 changes: 46 additions & 14 deletions ppstructure/README_ch.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
[English](README.md) | 简体中文

## 简介
- [1. 简介](#1)
- [2. 近期更新](#2)
- [3. 特性](#3)
- [4. 效果展示](#4)
* [4.1 版面分析和表格识别](#41)
* [4.2 VQA](#42)
- [5. 快速体验](#5)
- [6. PP-Structure 介绍](#6)
* [6.1 版面分析+表格识别](#61)
* [6.2 VQA](#62)
- [7. 模型库](#7)

<a name="1"></a>

## 1. 简介
PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包,旨在帮助开发者更好的完成文档理解相关任务。

## 近期更新
<a name="2"></a>

## 2. 近期更新
* 2021.12.07 新增VQA任务-SER和RE。

## 特性
<a name="3"></a>

## 3. 特性

PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包,主要特性如下:
- 支持对图片形式的文档进行版面分析,可以划分**文字、标题、表格、图片以及列表**5类区域(与Layout-Parser联合使用)
Expand All @@ -17,13 +35,17 @@ PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包
- 支持文档视觉问答(Document Visual Question Answering,DOC-VQA)任务-语义实体识别(Semantic Entity Recognition,SER)和关系抽取(Relation Extraction,RE)


## 1. 效果展示
<a name="4"></a>

## 4. 效果展示

<a name="41"></a>

### 1.1 版面分析和表格识别
### 4.1 版面分析和表格识别

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

### 1.2 VQA
### 4.2 VQA

* SER

Expand All @@ -46,32 +68,42 @@ PP-Structure是一个可用于复杂文档结构分析和处理的OCR工具包

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

## 2. 快速体验
<a name="5"></a>

## 5. 快速体验

代码体验:从 [快速安装](./docs/quickstart.md) 开始

## 3. PP-Structure Pipeline介绍
<a name="6"></a>

## 6. PP-Structure 介绍

### 3.1 版面分析+表格识别
PP-Structure 内置
<a name="61"></a>

### 6.1 版面分析+表格识别

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

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

#### 3.1.1 版面分析
#### 6.1.1 版面分析

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

#### 3.1.2 表格识别
#### 6.1.2 表格识别

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

<a name="62"></a>

### 6.2 VQA

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

coming soon
<a name="7"></a>

## 4. 模型库
## 7. 模型库

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

Expand Down
2 changes: 1 addition & 1 deletion ppstructure/predict_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from ppocr.utils.logging import get_logger
from tools.infer.predict_system import TextSystem
from ppstructure.table.predict_table import TableSystem, to_excel
from ppstructure.vqa.infer_ser_e2e import SerPredictor, draw_ser_results
from ppstructure.utility import parse_args, draw_structure_result

logger = get_logger()
Expand Down Expand Up @@ -66,6 +65,7 @@ def __init__(self, args):
self.use_angle_cls = args.use_angle_cls
self.drop_score = args.drop_score
elif self.mode == 'vqa':
from ppstructure.vqa.infer_ser_e2e import SerPredictor, draw_ser_results
self.vqa_engine = SerPredictor(args)

def __call__(self, img):
Expand Down
32 changes: 11 additions & 21 deletions ppstructure/vqa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ PP-Structure 里的 DOC-VQA算法基于PaddleNLP自然语言处理算法库进
- **(1) 安装PaddlePaddle**

```bash
pip3 install --upgrade pip
python3 -m pip install --upgrade pip

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

```bash
pip install paddleocr
python3 -m pip install paddleocr
```

- **(2)下载VQA源码(预测+训练)**
Expand All @@ -87,26 +87,16 @@ pip install paddleocr
【推荐】git clone https://github.com/PaddlePaddle/PaddleOCR

# 如果因为网络问题无法pull成功,也可选择使用码云上的托管:
git clone https://gitee.com/paddlepaddle/PaddleOCR
python3 -m pip clone https://gitee.com/paddlepaddle/PaddleOCR

# 注:码云托管代码可能无法实时同步本github项目更新,存在3~5天延时,请优先使用推荐方式。
```

- **(3)安装PaddleNLP**

```bash
# 需要使用PaddleNLP最新的代码版本进行安装
git clone https://github.com/PaddlePaddle/PaddleNLP -b develop
cd PaddleNLP
pip3 install -e .
```


- **(4)安装VQA的`requirements`**
- **(3)安装VQA的`requirements`**

```bash
cd ppstructure/vqa
pip install -r requirements.txt
python3 -m pip install -r requirements.txt
```

## 4. 使用
Expand All @@ -133,7 +123,7 @@ wget https://paddleocr.bj.bcebos.com/dataset/XFUND.tar
* 启动训练

```shell
python3.7 train_ser.py \
python3 train_ser.py \
--model_name_or_path "layoutxlm-base-uncased" \
--ser_model_type "LayoutXLM" \
--train_data_dir "XFUND/zh_train/image" \
Expand All @@ -154,7 +144,7 @@ python3.7 train_ser.py \
* 恢复训练

```shell
python3.7 train_ser.py \
python3 train_ser.py \
--model_name_or_path "model_path" \
--ser_model_type "LayoutXLM" \
--train_data_dir "XFUND/zh_train/image" \
Expand Down Expand Up @@ -191,7 +181,7 @@ python3 eval_ser.py \

```shell
export CUDA_VISIBLE_DEVICES=0
python3.7 infer_ser.py \
python3 infer_ser.py \
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
--ser_model_type "LayoutXLM" \
--output_dir "output/ser/" \
Expand All @@ -205,7 +195,7 @@ python3.7 infer_ser.py \

```shell
export CUDA_VISIBLE_DEVICES=0
python3.7 infer_ser_e2e.py \
python3 infer_ser_e2e.py \
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
--ser_model_type "LayoutXLM" \
--max_seq_length 512 \
Expand All @@ -217,7 +207,7 @@ python3.7 infer_ser_e2e.py \

```shell
export CUDA_VISIBLE_DEVICES=0
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
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
```


Expand Down Expand Up @@ -312,7 +302,7 @@ python3 infer_re.py \

```shell
export CUDA_VISIBLE_DEVICES=0
python3.7 infer_ser_re_e2e.py \
python3 infer_ser_re_e2e.py \
--model_name_or_path "PP-Layout_v1.0_ser_pretrained/" \
--re_model_name_or_path "PP-Layout_v1.0_re_pretrained/" \
--ser_model_type "LayoutXLM" \
Expand Down
3 changes: 2 additions & 1 deletion ppstructure/vqa/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sentencepiece
yacs
seqeval
seqeval
paddlenlp>=2.2.1

0 comments on commit 5e49f80

Please sign in to comment.