| 192 | |
| 193 | |
| 194 | def set_log_dir(root_dir, exp_name): |
| 195 | path_dict = {} |
| 196 | os.makedirs(root_dir, exist_ok=True) |
| 197 | |
| 198 | # set log path |
| 199 | exp_path = os.path.join(root_dir, exp_name) |
| 200 | now = datetime.now(dateutil.tz.tzlocal()) |
| 201 | timestamp = now.strftime('%Y_%m_%d_%H_%M_%S') |
| 202 | prefix = exp_path + '_' + timestamp |
| 203 | os.makedirs(prefix) |
| 204 | path_dict['prefix'] = prefix |
| 205 | |
| 206 | # set checkpoint path |
| 207 | ckpt_path = os.path.join(prefix, 'Model') |
| 208 | os.makedirs(ckpt_path) |
| 209 | path_dict['ckpt_path'] = ckpt_path |
| 210 | |
| 211 | log_path = os.path.join(prefix, 'Log') |
| 212 | os.makedirs(log_path) |
| 213 | path_dict['log_path'] = log_path |
| 214 | |
| 215 | # set sample image path for fid calculation |
| 216 | sample_path = os.path.join(prefix, 'Samples') |
| 217 | os.makedirs(sample_path) |
| 218 | path_dict['sample_path'] = sample_path |
| 219 | |
| 220 | return path_dict |
| 221 | |
| 222 | |
| 223 | def save_checkpoint(states, is_best, output_dir, |