From 340a8c24d063cfbd17ce9911446a832c72447206 Mon Sep 17 00:00:00 2001 From: WenmuZhou <572459439@qq.com> Date: Fri, 11 Mar 2022 00:09:27 +0000 Subject: [PATCH] add help --- ppstructure/layout/README.md | 2 +- ppstructure/layout/README_ch.md | 2 +- ppstructure/predict_system.py | 1 + ppstructure/utility.py | 7 ++++++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ppstructure/layout/README.md b/ppstructure/layout/README.md index 0931702a..3a4f5291 100644 --- a/ppstructure/layout/README.md +++ b/ppstructure/layout/README.md @@ -52,7 +52,7 @@ The following figure shows the result, with different colored detection boxes re | threshold | threshold of prediction score | 0.5 | \ | | input_shape | picture size of reshape | [3,640,640] | \ | | batch_size | testing batch size | 1 | \ | -| label_map | category mapping table | None | Setting config_ path, it can be none, and the label is automatically obtained according to the dataset name_ map | +| label_map | category mapping table | None | Setting config_ path, it can be none, and the label is automatically obtained according to the dataset name_ map, You need to specify it manually when setting model_path | | enforce_cpu | whether to use CPU | False | False to use GPU, and True to force the use of CPU | | enforce_mkldnn | whether mkldnn acceleration is enabled in CPU prediction | True | \ | | thread_num | the number of CPU threads | 10 | \ | diff --git a/ppstructure/layout/README_ch.md b/ppstructure/layout/README_ch.md index 6fec748b..825ff62b 100644 --- a/ppstructure/layout/README_ch.md +++ b/ppstructure/layout/README_ch.md @@ -52,7 +52,7 @@ show_img.show() | threshold | 预测得分的阈值 | 0.5 | \ | | input_shape | reshape之后图片尺寸 | [3,640,640] | \ | | batch_size | 测试batch size | 1 | \ | -| label_map | 类别映射表 | None | 设置config_path时,可以为None,根据数据集名称自动获取label_map | +| label_map | 类别映射表 | None | 设置config_path时,可以为None,根据数据集名称自动获取label_map,设置model_path时需要手动指定 | | enforce_cpu | 代码是否使用CPU运行 | False | 设置为False表示使用GPU,True表示强制使用CPU | | enforce_mkldnn | CPU预测中是否开启MKLDNN加速 | True | \ | | thread_num | 设置CPU线程数 | 10 | \ | diff --git a/ppstructure/predict_system.py b/ppstructure/predict_system.py index 3f3dc658..3ae52fdd 100644 --- a/ppstructure/predict_system.py +++ b/ppstructure/predict_system.py @@ -58,6 +58,7 @@ class OCRSystem(object): self.table_layout = lp.PaddleDetectionLayoutModel( config_path=config_path, model_path=model_path, + label_map=args.layout_label_map, threshold=0.5, enable_mkldnn=args.enable_mkldnn, enforce_cpu=not args.use_gpu, diff --git a/ppstructure/utility.py b/ppstructure/utility.py index ce7a801b..43cb0b08 100644 --- a/ppstructure/utility.py +++ b/ppstructure/utility.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import ast from PIL import Image import numpy as np from tools.infer.utility import draw_ocr_box_txt, init_args as infer_args @@ -34,7 +35,11 @@ def init_args(): "--layout_path_model", type=str, default="lp://PubLayNet/ppyolov2_r50vd_dcn_365e_publaynet/config") - + parser.add_argument( + "--layout_label_map", + type=ast.literal_eval, + default=None, + help='label map according to ppstructure/layout/README_ch.md') # params for ser parser.add_argument("--model_name_or_path", type=str) parser.add_argument("--max_seq_length", type=int, default=512) -- GitLab