From 13f5ee1e93dc29eae30e917cdb14b3e43795b206 Mon Sep 17 00:00:00 2001 From: LDOUBLEV Date: Wed, 16 Jun 2021 10:04:27 +0800 Subject: [PATCH] revert mp process, test=develop --- tools/infer/predict_system.py | 19 +++++++++++++++++-- tools/infer/utility.py | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/tools/infer/predict_system.py b/tools/infer/predict_system.py index 7361d27f..133b9a9d 100755 --- a/tools/infer/predict_system.py +++ b/tools/infer/predict_system.py @@ -13,6 +13,7 @@ # limitations under the License. import os import sys +import subprocess __dir__ = os.path.dirname(os.path.abspath(__file__)) sys.path.append(__dir__) @@ -93,7 +94,6 @@ class TextSystem(object): dt_boxes, elapse = self.text_detector(img) logger.debug("dt_boxes num : {}, elapse : {}".format( - len(dt_boxes), elapse)) if dt_boxes is None: return None, None @@ -147,6 +147,7 @@ def sorted_boxes(dt_boxes): def main(args): image_file_list = get_image_file_list(args.image_dir) + image_file_list = image_file_list[args.process_id::args.total_process_num] text_sys = TextSystem(args) is_visualize = True font_path = args.vis_font_path @@ -264,4 +265,18 @@ def main(args): if __name__ == "__main__": - main(utility.parse_args()) + args = utility.parse_args() + if args.use_mp: + p_list = [] + total_process_num = args.total_process_num + for process_id in range(total_process_num): + cmd = [sys.executable, "-u"] + sys.argv + [ + "--process_id={}".format(process_id), + "--use_mp={}".format(False) + ] + p = subprocess.Popen(cmd, stdout=sys.stdout, stderr=sys.stdout) + p_list.append(p) + for p in p_list: + p.wait() + else: + main(args) diff --git a/tools/infer/utility.py b/tools/infer/utility.py index 3b43efe4..d87666e6 100755 --- a/tools/infer/utility.py +++ b/tools/infer/utility.py @@ -106,6 +106,7 @@ def init_args(): parser.add_argument("--cpu_threads", type=int, default=10) parser.add_argument("--use_pdserving", type=str2bool, default=False) + # multi-process parser.add_argument("--use_mp", type=str2bool, default=False) parser.add_argument("--total_process_num", type=int, default=1) parser.add_argument("--process_id", type=int, default=0) @@ -113,7 +114,6 @@ def init_args(): parser.add_argument("--benchmark", type=bool, default=False) parser.add_argument("--save_log_path", type=str, default="./log_output/") - parser.add_argument("--show_log", type=str2bool, default=True) return parser -- GitLab