(self, save=True)
| 63 | self.initialized = True |
| 64 | |
| 65 | def parse(self, save=True): |
| 66 | if not self.initialized: |
| 67 | self.initialize() |
| 68 | self.opt = self.parser.parse_args() |
| 69 | self.opt.isTrain = self.isTrain # train or test |
| 70 | |
| 71 | str_ids = self.opt.gpu_ids.split(',') |
| 72 | self.opt.gpu_ids = [] |
| 73 | for str_id in str_ids: |
| 74 | id = int(str_id) |
| 75 | if id >= 0: |
| 76 | self.opt.gpu_ids.append(id) |
| 77 | |
| 78 | # set gpu ids |
| 79 | if len(self.opt.gpu_ids) > 0: |
| 80 | torch.cuda.set_device(self.opt.gpu_ids[0]) |
| 81 | |
| 82 | args = vars(self.opt) |
| 83 | |
| 84 | print('------------ Options -------------') |
| 85 | for k, v in sorted(args.items()): |
| 86 | print('%s: %s' % (str(k), str(v))) |
| 87 | print('-------------- End ----------------') |
| 88 | |
| 89 | # save to the disk |
| 90 | expr_dir = os.path.join(self.opt.checkpoints_dir, self.opt.name) |
| 91 | util.mkdirs(expr_dir) |
| 92 | if save and not self.opt.continue_train: |
| 93 | file_name = os.path.join(expr_dir, 'opt.txt') |
| 94 | with open(file_name, 'wt') as opt_file: |
| 95 | opt_file.write('------------ Options -------------\n') |
| 96 | for k, v in sorted(args.items()): |
| 97 | opt_file.write('%s: %s\n' % (str(k), str(v))) |
| 98 | opt_file.write('-------------- End ----------------\n') |
| 99 | return self.opt |
no test coverage detected