From bdf4e2f854ddeed0d5ac00f90563058bc8d2c4fb Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Tue, 23 Aug 2022 09:59:10 +0000 Subject: [PATCH 1/4] add eg of TEDS --- ppstructure/table/README.md | 34 +++++++++++++++++++++++++++++-- ppstructure/table/README_ch.md | 37 +++++++++++++++++++++++++++++++--- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index e5c85eb96..bbfd81b8e 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -79,6 +79,10 @@ python3.7 table/predict_table.py \ After the operation is completed, the excel table of each image will be saved to the directory specified by the output field, and an html file will be produced in the directory to visually view the cell coordinates and the recognized table. +**NOTE** +1. If you want to use the English table recognition model, you need to download the English text detection and recognition model and the English table recognition model in [models_list](../docs/models_list_en.md), and replace `table_structure_dict_ch.txt` with `table_structure_dict.txt`. +2. To use the TableRec-RARE model, you need to replace `table_structure_dict_ch.txt` with `table_structure_dict.txt`, and add parameter `--merge_no_span_structure=False` + ### 4.2 Train The training, evaluation and inference process of the text detection model can be referred to [detection](../../doc/doc_en/detection_en.md) @@ -114,9 +118,35 @@ python3 table/eval_table.py \ --gt_path=path/to/gt.txt ``` -If the PubLatNet eval dataset is used, it will be output +Evaluate on the PubLatNet dataset using the English model + ```bash -teds: 94.98 +cd PaddleOCR/ppstructure +# Download the model +mkdir inference && cd inference +# Download the detection model of the ultra-lightweight table English OCR model and unzip it +wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar && tar xf en_ppocr_mobile_v2.0_table_det_infer.tar +# Download the recognition model of the ultra-lightweight table English OCR model and unzip it +wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar && tar xf en_ppocr_mobile_v2.0_table_rec_infer.tar +# Download the PP-Structurev2 English table recognition model and unzip it +wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar && tar xf en_ppstructure_mobile_v2.0_SLANet_infer.tar +cd .. + +python3 table/eval_table.py \ + --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer \ + --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer \ + --table_model_dir=inference/en_ppstructure_mobile_v2.0_SLANet_infer \ + --image_dir=train_data/table/pubtabnet/val/ \ + --rec_char_dict_path=../ppocr/utils/dict/table_dict.txt \ + --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt \ + --det_limit_side_len=736 \ + --det_limit_type=min \ + --gt_path=path/to/gt.txt +``` + +output is +```bash +teds: 95.89 ``` ## 5. Reference diff --git a/ppstructure/table/README_ch.md b/ppstructure/table/README_ch.md index 086e39348..37cc7f660 100644 --- a/ppstructure/table/README_ch.md +++ b/ppstructure/table/README_ch.md @@ -67,7 +67,7 @@ mkdir inference && cd inference wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_infer.tar && tar xf ch_PP-OCRv3_det_infer.tar # 下载PP-OCRv3文本识别模型并解压 wget https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_rec_infer.tar && tar xf ch_PP-OCRv3_rec_infer.tar -# 下载PP-Structurev2表格识别模型并解压 +# 下载PP-Structurev2中文表格识别模型并解压 wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar && tar xf ch_ppstructure_mobile_v2.0_SLANet_infer.tar cd .. # 执行表格识别 @@ -82,6 +82,10 @@ python table/predict_table.py \ ``` 运行完成后,每张图片的excel表格会保存到output字段指定的目录下,同时在该目录下回生产一个html文件,用于可视化查看单元格坐标和识别的表格。 +**NOTE** +1. 如果想使用英文模型,需要在[models_list](../docs/models_list.md)中下载英文文字检测识别模型和英文表格识别模型,同时替换`table_structure_dict_ch.txt`为`table_structure_dict.txt`即可。 +2. 如需使用TableRec-RARE模型,需要替换`table_structure_dict_ch.txt`为`table_structure_dict.txt`,同时参数`--merge_no_span_structure=False` + ### 4.2 训练 文本检测模型的训练、评估和推理流程可参考 [detection](../../doc/doc_ch/detection.md) @@ -117,9 +121,36 @@ python3 table/eval_table.py \ --det_limit_type=min \ --gt_path=path/to/gt.txt ``` -如使用PubLatNet评估数据集,将会输出 + +如使用英文表格识别模型在PubLatNet数据集上进行评估 + ```bash -teds: 94.98 +cd PaddleOCR/ppstructure +# 下载模型 +mkdir inference && cd inference +# 下载超轻量级表格英文OCR模型的检测模型并解压 +wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar && tar xf en_ppocr_mobile_v2.0_table_det_infer.tar +# 下载超轻量级表格英文OCR模型的识别模型并解压 +wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar && tar xf en_ppocr_mobile_v2.0_table_rec_infer.tar +# 下载PP-Structurev2英文表格识别模型并解压 +wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar && tar xf en_ppstructure_mobile_v2.0_SLANet_infer.tar +cd .. + +python3 table/eval_table.py \ + --det_model_dir=inference/en_ppocr_mobile_v2.0_table_det_infer \ + --rec_model_dir=inference/en_ppocr_mobile_v2.0_table_rec_infer \ + --table_model_dir=inference/en_ppstructure_mobile_v2.0_SLANet_infer \ + --image_dir=train_data/table/pubtabnet/val/ \ + --rec_char_dict_path=../ppocr/utils/dict/table_dict.txt \ + --table_char_dict_path=../ppocr/utils/dict/table_structure_dict.txt \ + --det_limit_side_len=736 \ + --det_limit_type=min \ + --gt_path=path/to/gt.txt +``` + +将会输出 +```bash +teds: 95.89 ``` ## 5. Reference From dac5e17565c4fdfc9219ae3b9d741358bde1953a Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Tue, 23 Aug 2022 14:01:33 +0000 Subject: [PATCH 2/4] update doc --- ppstructure/table/README.md | 27 +++++++++++++++------------ ppstructure/table/README_ch.md | 14 ++++++++------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index bbfd81b8e..42ab29d98 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -2,14 +2,15 @@ English | [简体中文](README_ch.md) # Table Recognition -- [1. pipeline](#1-pipeline) -- [2. Performance](#2-performance) -- [3. Result](#3-result) -- [4. How to use](#4-how-to-use) - - [4.1 Quick start](#41-quick-start) - - [4.2 Train](#42-train) - - [4.3 Calculate TEDS](#43-calculate-teds) -- [5. Reference](#5-reference) +- [Table Recognition](#table-recognition) + - [1. pipeline](#1-pipeline) + - [2. Performance](#2-performance) + - [3. Result](#3-result) + - [4. How to use](#4-how-to-use) + - [4.1 Quick start](#41-quick-start) + - [4.2 Training, Evaluation and Inference](#42-training-evaluation-and-inference) + - [4.3 Calculate TEDS](#43-calculate-teds) + - [5. Reference](#5-reference) ## 1. pipeline @@ -51,6 +52,8 @@ The performance indicators are explained as follows: ### 4.1 Quick start +PP-Structure currently provides table recognition models in both Chinese and English. For the model link, see [models_list](../docs/models_list.md). The following takes the Chinese table recognition model as an example to introduce how to recognize a table. + Use the following commands to quickly complete the identification of a table. ```python @@ -83,7 +86,7 @@ After the operation is completed, the excel table of each image will be saved to 1. If you want to use the English table recognition model, you need to download the English text detection and recognition model and the English table recognition model in [models_list](../docs/models_list_en.md), and replace `table_structure_dict_ch.txt` with `table_structure_dict.txt`. 2. To use the TableRec-RARE model, you need to replace `table_structure_dict_ch.txt` with `table_structure_dict.txt`, and add parameter `--merge_no_span_structure=False` -### 4.2 Train +### 4.2 Training, Evaluation and Inference The training, evaluation and inference process of the text detection model can be referred to [detection](../../doc/doc_en/detection_en.md) @@ -124,11 +127,11 @@ Evaluate on the PubLatNet dataset using the English model cd PaddleOCR/ppstructure # Download the model mkdir inference && cd inference -# Download the detection model of the ultra-lightweight table English OCR model and unzip it +# Download the text detection model trained on the PubTabNet dataset and unzip it wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar && tar xf en_ppocr_mobile_v2.0_table_det_infer.tar -# Download the recognition model of the ultra-lightweight table English OCR model and unzip it +# Download the text recognition model trained on the PubTabNet dataset and unzip it wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar && tar xf en_ppocr_mobile_v2.0_table_rec_infer.tar -# Download the PP-Structurev2 English table recognition model and unzip it +# Download the table recognition model trained on the PubTabNet dataset and unzip it wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar && tar xf en_ppstructure_mobile_v2.0_SLANet_infer.tar cd .. diff --git a/ppstructure/table/README_ch.md b/ppstructure/table/README_ch.md index 37cc7f660..8aa0dc865 100644 --- a/ppstructure/table/README_ch.md +++ b/ppstructure/table/README_ch.md @@ -7,7 +7,7 @@ - [3. 效果演示](#3-效果演示) - [4. 使用](#4-使用) - [4.1 快速开始](#41-快速开始) - - [4.2 训练](#42-训练) + - [4.2 模型训练、评估与推理](#42-模型训练评估与推理) - [4.3 计算TEDS](#43-计算teds) - [5. Reference](#5-reference) @@ -57,6 +57,8 @@ ### 4.1 快速开始 +PP-Structure目前提供了中英文两种语言的表格识别模型,模型链接见 [models_list](../docs/models_list.md)。下面以中文表格识别模型为例,介绍如何识别一张表格。 + 使用如下命令即可快速完成一张表格的识别。 ```python cd PaddleOCR/ppstructure @@ -83,10 +85,10 @@ python table/predict_table.py \ 运行完成后,每张图片的excel表格会保存到output字段指定的目录下,同时在该目录下回生产一个html文件,用于可视化查看单元格坐标和识别的表格。 **NOTE** -1. 如果想使用英文模型,需要在[models_list](../docs/models_list.md)中下载英文文字检测识别模型和英文表格识别模型,同时替换`table_structure_dict_ch.txt`为`table_structure_dict.txt`即可。 +1. 如果想使用英文模型,需要在 [models_list](../docs/models_list.md) 中下载英文文字检测识别模型和英文表格识别模型,同时替换`table_structure_dict_ch.txt`为`table_structure_dict.txt`即可。 2. 如需使用TableRec-RARE模型,需要替换`table_structure_dict_ch.txt`为`table_structure_dict.txt`,同时参数`--merge_no_span_structure=False` -### 4.2 训练 +### 4.2 模型训练、评估与推理 文本检测模型的训练、评估和推理流程可参考 [detection](../../doc/doc_ch/detection.md) @@ -128,11 +130,11 @@ python3 table/eval_table.py \ cd PaddleOCR/ppstructure # 下载模型 mkdir inference && cd inference -# 下载超轻量级表格英文OCR模型的检测模型并解压 +# 下载基于PubTabNet数据集训练的文本检测模型并解压 wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_det_infer.tar && tar xf en_ppocr_mobile_v2.0_table_det_infer.tar -# 下载超轻量级表格英文OCR模型的识别模型并解压 +# 下载基于PubTabNet数据集训练的文本识别模型并解压 wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_rec_infer.tar && tar xf en_ppocr_mobile_v2.0_table_rec_infer.tar -# 下载PP-Structurev2英文表格识别模型并解压 +# 下载基于PubTabNet数据集训练的表格识别模型并解压 wget https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar && tar xf en_ppstructure_mobile_v2.0_SLANet_infer.tar cd .. From 82df900b298eca7d2d5243370b6b14bb40b5e417 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Tue, 23 Aug 2022 14:03:36 +0000 Subject: [PATCH 3/4] update doc --- ppstructure/table/README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index 42ab29d98..c606d6419 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -2,15 +2,14 @@ English | [简体中文](README_ch.md) # Table Recognition -- [Table Recognition](#table-recognition) - - [1. pipeline](#1-pipeline) - - [2. Performance](#2-performance) - - [3. Result](#3-result) - - [4. How to use](#4-how-to-use) - - [4.1 Quick start](#41-quick-start) - - [4.2 Training, Evaluation and Inference](#42-training-evaluation-and-inference) - - [4.3 Calculate TEDS](#43-calculate-teds) - - [5. Reference](#5-reference) +- [1. pipeline](#1-pipeline) +- [2. Performance](#2-performance) +- [3. Result](#3-result) +- [4. How to use](#4-how-to-use) + - [4.1 Quick start](#41-quick-start) + - [4.2 Training, Evaluation and Inference](#42-training-evaluation-and-inference) + - [4.3 Calculate TEDS](#43-calculate-teds) +- [5. Reference](#5-reference) ## 1. pipeline From cbd9571a171f6bf9e5d19aee680bc7cab6099acd Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Wed, 24 Aug 2022 02:08:45 +0000 Subject: [PATCH 4/4] rm imgaug version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 976d29192..cf80775f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ shapely scikit-image -imgaug==0.4.0 +imgaug pyclipper lmdb tqdm