From 5f9c92e3fb317568216c44c0cbe1d6f58733b615 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Fri, 28 Oct 2022 21:07:00 +0800 Subject: [PATCH] format config (#714) --- ppgan/utils/config.py | 10 ++++++++++ ppgan/utils/setup.py | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ppgan/utils/config.py b/ppgan/utils/config.py index 4ec02b1..c98e9fc 100644 --- a/ppgan/utils/config.py +++ b/ppgan/utils/config.py @@ -124,3 +124,13 @@ def get_config(fname, overrides=None, show=True): override_config(config, overrides) return config + + +def cfg2dict(cfg): + if isinstance(cfg, AttrDict): + cfg = dict(cfg) + for k in cfg.keys(): + if isinstance(cfg[k], AttrDict): + cfg[k] = cfg2dict(cfg[k]) + return cfg + \ No newline at end of file diff --git a/ppgan/utils/setup.py b/ppgan/utils/setup.py index c8c0c26..a439d3e 100644 --- a/ppgan/utils/setup.py +++ b/ppgan/utils/setup.py @@ -14,12 +14,13 @@ import os import time +import yaml import paddle import numpy as np import random +from .config import cfg2dict from .logger import setup_logger - def setup(args, cfg): if args.evaluate_only: cfg.is_train = False @@ -39,7 +40,7 @@ def setup(args, cfg): logger = setup_logger(cfg.output_dir) - logger.info('Configs: {}'.format(cfg)) + logger.info('Configs: \n{}'.format(yaml.dump(cfg2dict(cfg)))) if paddle.is_compiled_with_cuda(): paddle.set_device('gpu') -- GitLab