From 1a66977f3341c51f49ade5c354685b902deb7dc3 Mon Sep 17 00:00:00 2001 From: ritosonn <38173036+ritosonn@users.noreply.github.com> Date: Thu, 20 May 2021 09:52:28 +0900 Subject: [PATCH] [fix]: Fix a bug where logs are missing when two or more loggers were set (#1015) * +super().before_run() * flip reset_flag --- mmcv/runner/hooks/logger/mlflow.py | 3 ++- mmcv/runner/hooks/logger/pavi.py | 3 ++- mmcv/runner/hooks/logger/tensorboard.py | 3 ++- mmcv/runner/hooks/logger/wandb.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mmcv/runner/hooks/logger/mlflow.py b/mmcv/runner/hooks/logger/mlflow.py index 4967fec417..4e839340ef 100644 --- a/mmcv/runner/hooks/logger/mlflow.py +++ b/mmcv/runner/hooks/logger/mlflow.py @@ -13,7 +13,7 @@ def __init__(self, log_model=True, interval=10, ignore_last=True, - reset_flag=True, + reset_flag=False, by_epoch=True): """Class to log metrics and (optionally) a trained model to MLflow. @@ -60,6 +60,7 @@ def import_mlflow(self): @master_only def before_run(self, runner): + super(MlflowLoggerHook, self).before_run(runner) if self.exp_name is not None: self.mlflow.set_experiment(self.exp_name) if self.tags is not None: diff --git a/mmcv/runner/hooks/logger/pavi.py b/mmcv/runner/hooks/logger/pavi.py index 17c15b07b0..264d74abcd 100644 --- a/mmcv/runner/hooks/logger/pavi.py +++ b/mmcv/runner/hooks/logger/pavi.py @@ -22,7 +22,7 @@ def __init__(self, add_last_ckpt=False, interval=10, ignore_last=True, - reset_flag=True, + reset_flag=False, by_epoch=True, img_key='img_info'): super(PaviLoggerHook, self).__init__(interval, ignore_last, reset_flag, @@ -34,6 +34,7 @@ def __init__(self, @master_only def before_run(self, runner): + super(PaviLoggerHook, self).before_run(runner) try: from pavi import SummaryWriter except ImportError: diff --git a/mmcv/runner/hooks/logger/tensorboard.py b/mmcv/runner/hooks/logger/tensorboard.py index abb4ac4de5..f973047976 100644 --- a/mmcv/runner/hooks/logger/tensorboard.py +++ b/mmcv/runner/hooks/logger/tensorboard.py @@ -14,7 +14,7 @@ def __init__(self, log_dir=None, interval=10, ignore_last=True, - reset_flag=True, + reset_flag=False, by_epoch=True): super(TensorboardLoggerHook, self).__init__(interval, ignore_last, reset_flag, by_epoch) @@ -22,6 +22,7 @@ def __init__(self, @master_only def before_run(self, runner): + super(TensorboardLoggerHook, self).before_run(runner) if TORCH_VERSION < '1.1' or TORCH_VERSION == 'parrots': try: from tensorboardX import SummaryWriter diff --git a/mmcv/runner/hooks/logger/wandb.py b/mmcv/runner/hooks/logger/wandb.py index 38b597ae03..81220e644c 100644 --- a/mmcv/runner/hooks/logger/wandb.py +++ b/mmcv/runner/hooks/logger/wandb.py @@ -11,7 +11,7 @@ def __init__(self, init_kwargs=None, interval=10, ignore_last=True, - reset_flag=True, + reset_flag=False, commit=True, by_epoch=True, with_step=True): @@ -32,6 +32,7 @@ def import_wandb(self): @master_only def before_run(self, runner): + super(WandbLoggerHook, self).before_run(runner) if self.wandb is None: self.import_wandb() if self.init_kwargs: