From a6e6208d37e2dfe9b2fcb16a731a2f417511fc40 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Sat, 20 Aug 2022 07:18:30 +0000 Subject: [PATCH 1/5] update model size --- ppstructure/docs/models_list.md | 4 ++-- ppstructure/docs/models_list_en.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ppstructure/docs/models_list.md b/ppstructure/docs/models_list.md index ef2994cabe..0b2f41deb5 100644 --- a/ppstructure/docs/models_list.md +++ b/ppstructure/docs/models_list.md @@ -34,8 +34,8 @@ |模型名称|模型简介|推理模型大小|下载地址| | --- | --- | --- | --- | -|en_ppocr_mobile_v2.0_table_structure|基于TableRec-RARE在PubTabNet数据集上训练的英文表格识别模型|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) | -|en_ppstructure_mobile_v2.0_SLANet|基于SLANet在PubTabNet数据集上训练的英文表格识别模型|9M|[推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_train.tar) | +|en_ppocr_mobile_v2.0_table_structure|基于TableRec-RARE在PubTabNet数据集上训练的英文表格识别模型|6.8M|[推理模型](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) | +|en_ppstructure_mobile_v2.0_SLANet|基于SLANet在PubTabNet数据集上训练的英文表格识别模型|9.2M|[推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_train.tar) | |ch_ppstructure_mobile_v2.0_SLANet|基于SLANet在PubTabNet数据集上训练的中文表格识别模型|9.3M|[推理模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar) / [训练模型](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_train.tar) | diff --git a/ppstructure/docs/models_list_en.md b/ppstructure/docs/models_list_en.md index 64a7cdebc3..91f3286bf1 100644 --- a/ppstructure/docs/models_list_en.md +++ b/ppstructure/docs/models_list_en.md @@ -35,8 +35,8 @@ If you need to use other OCR models, you can download the model in [PP-OCR model |model| description |inference model size|download| | --- |-----------------------------------------------------------------------------| --- | --- | -|en_ppocr_mobile_v2.0_table_structure| English table recognition model trained on PubTabNet dataset based on TableRec-RARE |18.6M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar) | -|en_ppstructure_mobile_v2.0_SLANet|English table recognition model trained on PubTabNet dataset based on SLANet|9M|[inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_train.tar) | +|en_ppocr_mobile_v2.0_table_structure| English table recognition model trained on PubTabNet dataset based on TableRec-RARE |6.8M|[inference model](https://paddleocr.bj.bcebos.com/dygraph_v2.0/table/en_ppocr_mobile_v2.0_table_structure_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/dygraph_v2.1/table/en_ppocr_mobile_v2.0_table_structure_train.tar) | +|en_ppstructure_mobile_v2.0_SLANet|English table recognition model trained on PubTabNet dataset based on SLANet|9.2M|[inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/en_ppstructure_mobile_v2.0_SLANet_train.tar) | |ch_ppstructure_mobile_v2.0_SLANet|Chinese table recognition model trained on PubTabNet dataset based on SLANet|9.3M|[inference model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_infer.tar) / [trained model](https://paddleocr.bj.bcebos.com/ppstructure/models/slanet/ch_ppstructure_mobile_v2.0_SLANet_train.tar) | From 1cc7ad34cae92f92ab63b75a59454ac220ef2b85 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Sat, 20 Aug 2022 07:46:42 +0000 Subject: [PATCH 2/5] update layout dict in whl --- paddleocr.py | 3 ++- tools/infer/utility.py | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/paddleocr.py b/paddleocr.py index 8e34c4fbc3..f6318ad20f 100644 --- a/paddleocr.py +++ b/paddleocr.py @@ -289,7 +289,8 @@ MODEL_URLS = { 'ch': { 'url': 'https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_layout_infer.tar', - 'dict_path': 'ppocr/utils/dict/layout_publaynet_dict.txt' + 'dict_path': + 'ppocr/utils/dict/layout_dict/layout_publaynet_dict.txt' } } } diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 1eebc73f31..1355ca62e5 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -181,14 +181,21 @@ def create_predictor(args, mode, logger): return sess, sess.get_inputs()[0], None, None else: - model_file_path = model_dir + "/inference.pdmodel" - params_file_path = model_dir + "/inference.pdiparams" + file_names = ['model', 'inference'] + for file_name in file_names: + model_file_path = '{}/{}.pdmodel'.format(model_dir, file_name) + params_file_path = '{}/{}.pdiparams'.format(model_dir, file_name) + if os.path.exists(model_file_path) and os.path.exists( + params_file_path): + break if not os.path.exists(model_file_path): - raise ValueError("not find model file path {}".format( - model_file_path)) + raise ValueError( + "not find model.pdmodel or inference.pdmodel in {}".format( + model_dir)) if not os.path.exists(params_file_path): - raise ValueError("not find params file path {}".format( - params_file_path)) + raise ValueError( + "not find model.pdiparams or inference.pdiparams in {}".format( + model_dir)) config = inference.Config(model_file_path, params_file_path) From f6ba46b396c6be405184824518663f033206f4b2 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Sat, 20 Aug 2022 08:40:40 +0000 Subject: [PATCH 3/5] update metric --- ppstructure/table/README.md | 2 +- ppstructure/table/README_ch.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index 3732a89c54..3bf8685617 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -33,7 +33,7 @@ We evaluated the algorithm on the PubTabNet[1] eval dataset, and the |Method|Acc|[TEDS(Tree-Edit-Distance-based Similarity)](https://github.com/ibm-aur-nlp/PubTabNet/tree/master/src)|Speed| | --- | --- | --- | ---| | EDD[2] |x| 88.3 |x| -| TableRec-RARE(ours) |73.8%| 95.3% |1550ms| +| TableRec-RARE(ours) | 71.73%| 93.88% |779ms| | SLANet(ours) | 76.2%| 95.85% |766ms| The performance indicators are explained as follows: diff --git a/ppstructure/table/README_ch.md b/ppstructure/table/README_ch.md index cc73f8bcec..cdbea58103 100644 --- a/ppstructure/table/README_ch.md +++ b/ppstructure/table/README_ch.md @@ -39,7 +39,7 @@ |算法|Acc|[TEDS(Tree-Edit-Distance-based Similarity)](https://github.com/ibm-aur-nlp/PubTabNet/tree/master/src)|Speed| | --- | --- | --- | ---| | EDD[2] |x| 88.3% |x| -| TableRec-RARE(ours) |73.8%| 95.3% |1550ms| +| TableRec-RARE(ours) | 71.73%| 93.88% |779ms| | SLANet(ours) | 76.2%| 95.85% |766ms| 性能指标解释如下: From 40a3a1cfc21f95bf68be4b000356f7798a11aa83 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Sat, 20 Aug 2022 08:48:01 +0000 Subject: [PATCH 4/5] update metric --- ppstructure/table/README.md | 2 +- ppstructure/table/README_ch.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ppstructure/table/README.md b/ppstructure/table/README.md index 3bf8685617..a5d0da3ccd 100644 --- a/ppstructure/table/README.md +++ b/ppstructure/table/README.md @@ -34,7 +34,7 @@ We evaluated the algorithm on the PubTabNet[1] eval dataset, and the | --- | --- | --- | ---| | EDD[2] |x| 88.3 |x| | TableRec-RARE(ours) | 71.73%| 93.88% |779ms| -| SLANet(ours) | 76.2%| 95.85% |766ms| +| SLANet(ours) | 76.31%| 95.89%|766ms| The performance indicators are explained as follows: - Acc: The accuracy of the table structure in each image, a wrong token is considered an error. diff --git a/ppstructure/table/README_ch.md b/ppstructure/table/README_ch.md index cdbea58103..e83c81befb 100644 --- a/ppstructure/table/README_ch.md +++ b/ppstructure/table/README_ch.md @@ -40,7 +40,7 @@ | --- | --- | --- | ---| | EDD[2] |x| 88.3% |x| | TableRec-RARE(ours) | 71.73%| 93.88% |779ms| -| SLANet(ours) | 76.2%| 95.85% |766ms| +| SLANet(ours) |76.31%| 95.89%|766ms| 性能指标解释如下: - Acc: 模型对每张图像里表格结构的识别准确率,错一个token就算错误。 From 66f4ae0261e42ca94f6ba19f73f76bd452873d98 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Mon, 22 Aug 2022 02:25:24 +0000 Subject: [PATCH 5/5] fix is_nlp_model not define error in save_model --- ppocr/utils/save_load.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ppocr/utils/save_load.py b/ppocr/utils/save_load.py index 0c652c8fdc..f86125521d 100644 --- a/ppocr/utils/save_load.py +++ b/ppocr/utils/save_load.py @@ -194,6 +194,9 @@ def save_model(model, _mkdir_if_not_exist(model_path, logger) model_prefix = os.path.join(model_path, prefix) paddle.save(optimizer.state_dict(), model_prefix + '.pdopt') + + is_nlp_model = config['Architecture']["model_type"] == 'kie' and config[ + "Architecture"]["algorithm"] not in ["SDMGR"] if is_nlp_model is not True: paddle.save(model.state_dict(), model_prefix + '.pdparams') metric_prefix = model_prefix