def _get_child_configer_transform(self, child_config_file): dataset_configer = Configer(configs=child_config_file) child_configer = self.configer.clone() child_configer.params_root['data'].update(dataset_configer.get('data')) if self.configer.exists( 'use_adaptive_transform') or self.dataset == 'val': child_configer.params_root.update({ 'train_trans': dataset_configer.params_root['train_trans'], 'val_trans': dataset_configer.params_root['val_trans'], }) return child_configer, CV2AugCompose(split=self.dataset, configer=child_configer)
args_parser = parser.parse_args() from lib.utils.distributed import handle_distributed handle_distributed(args_parser, os.path.expanduser(os.path.abspath(__file__))) if args_parser.seed is not None: random.seed(args_parser.seed) torch.manual_seed(args_parser.seed) cudnn.enabled = True cudnn.benchmark = args_parser.cudnn configer = Configer(args_parser=args_parser) data_dir = configer.get('data', 'data_dir') if isinstance(data_dir, str): data_dir = [data_dir] abs_data_dir = [os.path.expanduser(x) for x in data_dir] configer.update(['data', 'data_dir'], abs_data_dir) project_dir = os.path.dirname(os.path.realpath(__file__)) configer.add(['project_dir'], project_dir) if configer.get('logging', 'log_to_file'): log_file = configer.get('logging', 'log_file') new_log_file = '{}_{}'.format( log_file, time.strftime("%Y-%m-%d_%X", time.localtime())) configer.update(['logging', 'log_file'], new_log_file) else: configer.update(['logging', 'logfile_level'], None)
args_parser = parser.parse_args() from lib.utils.distributed import handle_distributed handle_distributed(args_parser, os.path.expanduser(os.path.abspath(__file__))) if args_parser.seed is not None: random.seed(args_parser.seed) torch.manual_seed(args_parser.seed) cudnn.enabled = True cudnn.benchmark = args_parser.cudnn configer = Configer(args_parser=args_parser) abs_data_dir = os.path.expanduser(configer.get('data', 'data_dir')) configer.update(['data', 'data_dir'], abs_data_dir) project_dir = os.path.dirname(os.path.realpath(__file__)) configer.add(['project_dir'], project_dir) if configer.get('logging', 'log_to_file'): log_file = configer.get('logging', 'log_file') new_log_file = '{}_{}'.format( log_file, time.strftime("%Y-%m-%d_%X", time.localtime())) configer.update(['logging', 'log_file'], new_log_file) else: configer.update(['logging', 'logfile_level'], None) Log.init(logfile_level=configer.get('logging', 'logfile_level'), stdout_level=configer.get('logging', 'stdout_level'),
default=False, dest='distributed', help='Use CUDNN.') args_parser = parser.parse_args() if args_parser.seed is not None: random.seed(args_parser.seed + args_parser.local_rank) torch.manual_seed(args_parser.seed + args_parser.local_rank) if args_parser.gpu is not None: torch.cuda.manual_seed_all(args_parser.seed + args_parser.local_rank) configer = Configer(args_parser=args_parser) cudnn.enabled = True if configer.get('data', 'multiscale') is None: cudnn.benchmark = args_parser.cudnn else: cudnn.benchmark = False if configer.get('gpu') is not None and not configer.get('distributed', default=False): os.environ["CUDA_VISIBLE_DEVICES"] = ','.join( str(gpu_id) for gpu_id in configer.get('gpu')) if configer.get('network', 'norm_type') is None: configer.update('network.norm_type', 'batchnorm') if torch.cuda.device_count() <= 1 or configer.get('distributed', default=False): configer.update('network.gather', True)
args_parser = parser.parse_args() from lib.utils.distributed import handle_distributed handle_distributed(args_parser, os.path.expanduser(os.path.abspath(__file__))) if args_parser.seed is not None: random.seed(args_parser.seed) torch.manual_seed(args_parser.seed) cudnn.enabled = True cudnn.benchmark = args_parser.cudnn print(args_parser) configer = Configer(args_parser=args_parser) data_dir = configer.get('data', 'data_dir') if isinstance(data_dir, str): data_dir = [data_dir] abs_data_dir = [os.path.expanduser(x) for x in data_dir] configer.update(['data', 'data_dir'], abs_data_dir) project_dir = os.path.dirname(os.path.realpath(__file__)) configer.add(['project_dir'], project_dir) if configer.get('logging', 'log_to_file'): log_file = configer.get('logging', 'log_file') new_log_file = '{}_{}'.format( log_file, time.strftime("%Y-%m-%d_%X", time.localtime())) configer.update(['logging', 'log_file'], new_log_file) else: configer.update(['logging', 'logfile_level'], None)
# *********** Params for env. ********** parser.add_argument('--seed', default=None, type=int, help='manual seed') parser.add_argument('--cudnn', type=str2bool, nargs='?', default=True, help='Use CUDNN.') args_parser = parser.parse_args() if args_parser.seed is not None: random.seed(args_parser.seed) torch.manual_seed(args_parser.seed) cudnn.enabled = True cudnn.benchmark = args_parser.cudnn configer = Configer(args_parser=args_parser) abs_data_dir = os.path.expanduser(configer.get('data', 'data_dir')) configer.update(['data', 'data_dir'], abs_data_dir) if configer.get('gpu') is not None: os.environ["CUDA_VISIBLE_DEVICES"] = ','.join(str(gpu_id) for gpu_id in configer.get('gpu')) project_dir = os.path.dirname(os.path.realpath(__file__)) configer.add(['project_dir'], project_dir) if configer.get('logging', 'log_to_file'): log_file = configer.get('logging', 'log_file') new_log_file = '{}_{}'.format(log_file, time.strftime("%Y-%m-%d_%X", time.localtime())) configer.update(['logging', 'log_file'], new_log_file) else: configer.update(['logging', 'logfile_level'], None)