From aedeb28a56c51fb9c007bc711385da11e76f3173 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Mon, 22 Aug 2022 16:31:54 +0800 Subject: [PATCH] fix re bug (#7288) --- tools/infer/utility.py | 29 +++++++++++++++-------------- tools/infer_kie_token_ser_re.py | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index a547bbdb..8d3e9399 100644 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -225,23 +225,24 @@ def create_predictor(args, mode, logger): min_subgraph_size, # skip the minmum trt subgraph use_calib_mode=False) - # collect shape - if args.shape_info_filename is not None: - if not os.path.exists(args.shape_info_filename): - config.collect_shape_range_info(args.shape_info_filename) - logger.info( - f"collect dynamic shape info into : {args.shape_info_filename}" - ) + # collect shape + if args.shape_info_filename is not None: + if not os.path.exists(args.shape_info_filename): + config.collect_shape_range_info( + args.shape_info_filename) + logger.info( + f"collect dynamic shape info into : {args.shape_info_filename}" + ) + else: + logger.info( + f"dynamic shape info file( {args.shape_info_filename} ) already exists, not need to generate again." + ) + config.enable_tuned_tensorrt_dynamic_shape( + args.shape_info_filename, True) else: logger.info( - f"dynamic shape info file( {args.shape_info_filename} ) already exists, not need to generate again." + f"when using tensorrt, dynamic shape is a suggested option, you can use '--shape_info_filename=shape.txt' for offline dygnamic shape tuning" ) - config.enable_tuned_tensorrt_dynamic_shape( - args.shape_info_filename, True) - else: - logger.info( - f"when using tensorrt, dynamic shape is a suggested option, you can use '--shape_info_filename=shape.txt' for offline dygnamic shape tuning" - ) elif args.use_xpu: config.enable_xpu(10 * 1024 * 1024) diff --git a/tools/infer_kie_token_ser_re.py b/tools/infer_kie_token_ser_re.py index 40784e39..3ee696f2 100755 --- a/tools/infer_kie_token_ser_re.py +++ b/tools/infer_kie_token_ser_re.py @@ -39,7 +39,7 @@ from ppocr.utils.visual import draw_re_results from ppocr.utils.logging import get_logger from ppocr.utils.utility import get_image_file_list, load_vqa_bio_label_maps, print_dict from tools.program import ArgsParser, load_config, merge_config -from tools.infer_vqa_token_ser import SerPredictor +from tools.infer_kie_token_ser import SerPredictor class ReArgsParser(ArgsParser): -- GitLab