From b4c569e835175155af575eec403a84119de4fda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E5=B3=BB=E8=B1=AA?= <12132342@mail.sustech.edu.cn> Date: Wed, 20 Oct 2021 22:55:43 +0800 Subject: [PATCH] fix bug: init message manager when test phase --- lib/main.py | 7 +++++-- lib/utils/msg_manager.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/main.py b/lib/main.py index 7be5cf0..e8b033f 100644 --- a/lib/main.py +++ b/lib/main.py @@ -24,8 +24,11 @@ def initialization(cfgs, training): engine_cfg = cfgs['trainer_cfg'] if training else cfgs['evaluator_cfg'] output_path = os.path.join('output/', cfgs['data_cfg']['dataset_name'], cfgs['model_cfg']['model'], engine_cfg['save_name']) - msg_mgr.init_manager(output_path, opt.log_to_file, engine_cfg['log_iter'] if training else 0, - engine_cfg['restore_hint'] if isinstance(engine_cfg['restore_hint'], (int)) else 0) + if training: + msg_mgr.init_manager(output_path, opt.log_to_file, engine_cfg['log_iter'], + engine_cfg['restore_hint'] if isinstance(engine_cfg['restore_hint'], (int)) else 0) + else: + msg_mgr.init_logger(output_path, opt.log_to_file) msg_mgr.log_info(engine_cfg) diff --git a/lib/utils/msg_manager.py b/lib/utils/msg_manager.py index 3dad592..b464a19 100644 --- a/lib/utils/msg_manager.py +++ b/lib/utils/msg_manager.py @@ -23,7 +23,9 @@ class MessageManager: mkdir(osp.join(save_path, "summary/")) self.writer = SummaryWriter( osp.join(save_path, "summary/"), purge_step=self.iteration) + self.init_logger(save_path, log_to_file) + def init_logger(self, save_path, log_to_file): # init logger self.logger = logging.getLogger('opengait') self.logger.setLevel(logging.INFO)