From 2942cfe616aa2f27500e195b6cb18a6c27da4087 Mon Sep 17 00:00:00 2001 From: chenguowei01 Date: Tue, 12 May 2020 16:34:28 +0800 Subject: [PATCH] update visualdl --- contrib/HumanSeg/models/humanseg.py | 26 +++++++++----------------- contrib/HumanSeg/requirements.txt | 8 +------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/contrib/HumanSeg/models/humanseg.py b/contrib/HumanSeg/models/humanseg.py index cca23954..028fab16 100644 --- a/contrib/HumanSeg/models/humanseg.py +++ b/contrib/HumanSeg/models/humanseg.py @@ -493,10 +493,7 @@ class SegModel(object): if use_vdl: from visualdl import LogWriter vdl_logdir = osp.join(save_dir, 'vdl_log') - log_writer = LogWriter(vdl_logdir, sync_cycle=20) - train_step_component = OrderedDict() - eval_component = OrderedDict() - + log_writer = LogWriter(vdl_logdir) best_miou = -1.0 best_model_epoch = 1 for i in range(self.begin_epoch, num_epochs): @@ -527,13 +524,10 @@ class SegModel(object): if use_vdl: for k, v in step_metrics.items(): - if k not in train_step_component.keys(): - with log_writer.mode('Each_step_while_Training' - ) as step_logger: - train_step_component[ - k] = step_logger.scalar( - 'Training: {}'.format(k)) - train_step_component[k].add_record(num_steps, v) + log_writer.add_scalar( + step=num_steps, + tag='train/{}'.format(k), + value=v) # 计算剩余时间 avg_step_time = np.mean(time_stat) @@ -587,12 +581,10 @@ class SegModel(object): if isinstance(v, np.ndarray): if v.size > 1: continue - if k not in eval_component: - with log_writer.mode('Each_Epoch_on_Eval_Data' - ) as eval_logger: - eval_component[k] = eval_logger.scalar( - 'Evaluation: {}'.format(k)) - eval_component[k].add_record(i + 1, v) + log_writer.add_scalar( + step=num_steps, + tag='evaluate/{}'.format(k), + value=v) self.save_model(save_dir=current_save_dir) time_eval_one_epoch = time.time() - eval_epoch_start_time if eval_dataset is not None: diff --git a/contrib/HumanSeg/requirements.txt b/contrib/HumanSeg/requirements.txt index e90d7dab..ab6d60ab 100644 --- a/contrib/HumanSeg/requirements.txt +++ b/contrib/HumanSeg/requirements.txt @@ -1,10 +1,4 @@ -pre-commit -yapf == 0.26.0 -flake8 pyyaml >= 5.1 -visualdl >= 1.3.0 +visualdl == 2.0.0-alpha.1 Pillow -numpy -six -opencv-python tqdm -- GitLab