diff --git a/yolox/core/trainer.py b/yolox/core/trainer.py index 85921ef2e..41fecc172 100644 --- a/yolox/core/trainer.py +++ b/yolox/core/trainer.py @@ -204,14 +204,15 @@ def after_train(self): if self.args.logger == "wandb": self.wandb_logger.finish() elif self.args.logger == "mlflow": - metadata={ + metadata = { "epoch": self.epoch + 1, "input_size": self.input_size, 'start_ckpt': self.args.ckpt, 'exp_file': self.args.exp_file, "best_ap": float(self.best_ap) } - self.mlflow_logger.on_train_end(self.args, file_name=self.file_name, metadata=metadata) + self.mlflow_logger.on_train_end(self.args, file_name=self.file_name, + metadata=metadata) def before_epoch(self): logger.info("---> start train epoch{}".format(self.epoch + 1)) diff --git a/yolox/utils/logger.py b/yolox/utils/logger.py index 48320057c..1045a7b47 100644 --- a/yolox/utils/logger.py +++ b/yolox/utils/logger.py @@ -98,11 +98,8 @@ def setup_logger(save_dir, distributed_rank=0, filename="log.txt", mode="a"): logger.remove() save_file = os.path.join(save_dir, filename) - crnt_log_save_file = os.path.join(save_dir, 'train_log_crnt.txt') if mode == "o" and os.path.exists(save_file): os.remove(save_file) - if os.path.exists(crnt_log_save_file): - os.remove(crnt_log_save_file) # only keep logger in rank0 process if distributed_rank == 0: logger.add( @@ -112,7 +109,6 @@ def setup_logger(save_dir, distributed_rank=0, filename="log.txt", mode="a"): enqueue=True, ) logger.add(save_file) - logger.add(crnt_log_save_file) # redirect stdout/stderr to loguru redirect_sys_output("INFO") diff --git a/yolox/utils/mlflow_logger.py b/yolox/utils/mlflow_logger.py index ef63321ed..28b031822 100644 --- a/yolox/utils/mlflow_logger.py +++ b/yolox/utils/mlflow_logger.py @@ -23,6 +23,8 @@ from loguru import logger import torch from yolox.utils import is_main_process + + class MlflowLogger: """ Main Mlflow logging class to log hyperparameters, metrics, and models to Mlflow. @@ -156,10 +158,8 @@ def setup(self, args, exp): self._mlflow_log_model_per_n_epochs = int(os.getenv( "YOLOX_MLFLOW_LOG_MODEL_PER_n_EPOCHS", 30)) - self._mlflow_log_nth_epoch_models = os.getenv( - "YOLOX_MLFLOW_LOG_Nth_EPOCH_MODELS", "False").upper() in \ - self.ENV_VARS_TRUE_VALUES - + self._mlflow_log_nth_epoch_models = os.getenv("YOLOX_MLFLOW_LOG_Nth_EPOCH_MODELS", + "False").upper() in self.ENV_VARS_TRUE_VALUES self.run_name = os.getenv("YOLOX_MLFLOW_RUN_NAME", None) self.run_name = None if len(self.run_name.strip()) == 0 else self.run_name self._flatten_params = os.getenv("YOLOX_MLFLOW_FLATTEN_PARAMS", @@ -283,7 +283,7 @@ def on_log(self, args, exp, step, logs): Returns: None """ - #step = trainer.progress_in_iter + # step = trainer.progress_in_iter if not self._initialized: self.setup(args, exp) if is_main_process(): # master thread only @@ -340,7 +340,7 @@ def save_log_file(self, args, file_name): Returns: None """ - log_file_path = os.path.join(file_name, "train_log_crnt.txt") + log_file_path = os.path.join(file_name, "train_log.txt") mlflow_out_dir = f"{args.experiment_name}" logger.info(f"Logging logfile: {log_file_path} in mlflow artifact path: {mlflow_out_dir}.") self._ml_flow.log_artifact(log_file_path, mlflow_out_dir)