Print and save options It will print both current options and default values(if different). It will save options into a text file / [checkpoints_dir] / opt.txt
(self, opt)
| 81 | return parser.parse_args() |
| 82 | |
| 83 | def print_options(self, opt): |
| 84 | """Print and save options |
| 85 | |
| 86 | It will print both current options and default values(if different). |
| 87 | It will save options into a text file / [checkpoints_dir] / opt.txt |
| 88 | """ |
| 89 | message = '' |
| 90 | message += '----------------- Options ---------------\n' |
| 91 | for k, v in sorted(vars(opt).items()): |
| 92 | comment = '' |
| 93 | default = self.parser.get_default(k) |
| 94 | if v != default: |
| 95 | comment = '\t[default: %s]' % str(default) |
| 96 | message += '{:>25}: {:<30}{}\n'.format(str(k), str(v), comment) |
| 97 | message += '----------------- End -------------------' |
| 98 | print(message) |
| 99 | |
| 100 | # save to the disk |
| 101 | expr_dir = os.path.join(opt.checkpoints_dir, opt.name) |
| 102 | util.mkdirs(expr_dir) |
| 103 | file_name = os.path.join(expr_dir, '{}_opt.txt'.format(opt.phase)) |
| 104 | with open(file_name, 'wt') as opt_file: |
| 105 | opt_file.write(message) |
| 106 | opt_file.write('\n') |
| 107 | |
| 108 | def parse(self): |
| 109 | """Parse our options, create checkpoints directory suffix, and set up gpu device.""" |