MCPcopy
hub / github.com/OpenMotionLab/MotionGPT / create_logger

Function create_logger

mGPT/utils/logger.py:8–33  ·  view source on GitHub ↗
(cfg, phase='train')

Source from the content-addressed store, hash-verified

6from pytorch_lightning.utilities.rank_zero import rank_zero_only
7
8def create_logger(cfg, phase='train'):
9 # root dir set by cfg
10 root_output_dir = Path(cfg.FOLDER)
11 # set up logger
12 if not root_output_dir.exists():
13 print('=> creating {}'.format(root_output_dir))
14 root_output_dir.mkdir()
15
16 cfg_name = cfg.NAME
17 model = cfg.model.target.split('.')[-2]
18 cfg_name = os.path.basename(cfg_name).split('.')[0]
19
20 final_output_dir = root_output_dir / model / cfg_name
21 cfg.FOLDER_EXP = str(final_output_dir)
22
23 time_str = time.strftime('%Y-%m-%d-%H-%M-%S')
24
25 new_dir(cfg, phase, time_str, final_output_dir)
26
27 head = '%(asctime)-15s %(message)s'
28 logger = config_logger(final_output_dir, time_str, phase, head)
29 if logger is None:
30 logger = logging.getLogger()
31 logger.setLevel(logging.CRITICAL)
32 logging.basicConfig(format=head)
33 return logger
34
35
36@rank_zero_only

Callers 3

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 2

new_dirFunction · 0.85
config_loggerFunction · 0.85

Tested by 1

mainFunction · 0.72