# ----------------- get options ----------------- # with open(osp.join(args.exp_dir, args.opt), 'r') as f: opt = yaml.load(f.read(), Loader=yaml.FullLoader) # ----------------- general configs ----------------- # # experiment dir opt['exp_dir'] = args.exp_dir # random seed base_utils.setup_random_seed(opt['manual_seed']) # logger base_utils.setup_logger('base') opt['verbose'] = opt.get('verbose', False) # device if args.gpu_id >= 0: os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_id) if torch.cuda.is_available(): torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False opt['device'] = 'cuda' else: opt['device'] = 'cpu' else: opt['device'] = 'cpu'
# experiment dir opt['exp_dir'] = args.exp_dir # random seed base_utils.setup_random_seed(opt['manual_seed']) # logger if args.mode == 'train' or args.mode == 'test': if args.mode == 'train': logpath = osp.join('results', opt['dataset']['train']['name'], opt['experiment']) else: logpath = osp.join('results', opt['dataset']['name'], opt['experiment']) if not osp.exists(logpath): os.mkdir(logpath) logpath = logpath + '/train.log' base_utils.setup_logger('base', filepath=logpath) opt['verbose'] = opt.get('verbose', False) # device if args.gpu_id >= 0: # os.environ['CUDA_VISIBLE_DEVICES'] = str(args.gpu_id) if torch.cuda.is_available(): torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False opt['device'] = 'cuda' else: opt['device'] = 'cpu' else: opt['device'] = 'cpu'