def get_cfg(): cfg = get_main_config() cfg.batch_size = 100 cfg.nframes = 3 cfg.frame_size = 350 cfg.N = cfg.nframes cfg.dynamic.frame_size = cfg.frame_size cfg.dynamic.frames = cfg.nframes cfg.gpuid = 0 cfg.random_seed = 0 cfg.bss_str = '0m_2f_200t_d' cfg.bss_batch_size = 100 cfg.npatches = 6 cfg.patchsize = 3 cfg.nblocks = 3 cfg.nh_size = cfg.nblocks # old name cfg.explore_package = "lpas" # -- pick package to explore -- cfg.explore_dir = Path( ROOT_PATH) / f"./output/explore/{cfg.explore_package}/" if not cfg.explore_dir.exists(): cfg.explore_dir.mkdir(parents=True) cfg.bss_dir = cfg.explore_dir / "./bss/" if not cfg.bss_dir.exists(): cfg.bss_dir.mkdir(parents=True) cfg.drop_last = {'tr': True, 'val': True, 'te': True} # -- set noise params -- nconfig = get_noise_config(cfg, "g-75p0") cfg.noise_type = nconfig.ntype cfg.noise_params = nconfig return cfg
def setup_exp_cfg(base_cfg,exp): # -- create a copy -- cfg = copy.deepcopy(base_cfg) # -- random seed -- cfg.random_seed = exp.random_seed # -- number of frames -- cfg.nframes = int(exp.nframes) # -- bootstrapping name -- cfg.score_fxn_name = exp.bsname # -- batchsize -- cfg.batch_size = int(exp.batch_size) # -- combinatoric search info -- cfg.nblocks = int(exp.nblocks) cfg.patchsize = int(exp.patchsize) # -- set noise params -- nconfig = get_noise_config(cfg,exp.noise_type) cfg.noise_type = nconfig.ntype cfg.noise_params = nconfig # -- dynamics function -- cfg.dynamic_info.ppf = exp.ppf cfg.dynamic_info.total_pixels = cfg.dynamic_info.ppf*(cfg.nframes-1) cfg.dynamic_info.nframes = exp.nframes return cfg
def init_exp(cfg,exp): # -- set patchsize -- cfg.patchsize = int(exp.patchsize) # -- set patchsize -- cfg.nframes = int(exp.nframes) cfg.N = cfg.nframes # -- set number of blocks (old: neighborhood size) -- cfg.nblocks = int(exp.nblocks) cfg.nh_size = cfg.nblocks # old name # -- get noise function -- nconfig = get_noise_config(cfg,exp.noise_type) noise_xform = get_noise_transform(nconfig,use_to_tensor=False) # -- get dynamics function -- cfg.dynamic.ppf = exp.ppf cfg.dynamic.bool = True cfg.dynamic.random_eraser = False cfg.dynamic.frame_size = cfg.frame_size cfg.dynamic.total_pixels = cfg.dynamic.ppf*(cfg.nframes-1) cfg.dynamic.frames = exp.nframes def nonoise(image): return image dynamic_info = cfg.dynamic dynamic_raw_xform = get_dynamic_transform(dynamic_info,nonoise) dynamic_xform = dynamic_wrapper(dynamic_raw_xform) # -- get score function -- score_function = get_score_function(exp.score_function) return noise_xform,dynamic_xform,score_function
def setup_exp_cfg(base_cfg, exp): # -- create a copy -- cfg = copy.deepcopy(base_cfg) # -- random seed -- cfg.random_seed = exp.random_seed # -- set frame size cfg.frame_size = frame_size_from_str(exp.frame_size) cfg.dynamic_info.frame_size = cfg.frame_size # -- fix dataset -- cfg.dataset.name = exp.dataset # -- number of frames -- cfg.image_xform = exp.image_xform # -- number of frames -- cfg.nframes = int(exp.nframes) # -- batchsize -- cfg.batch_size = int(exp.batch_size) # -- neural network -- cfg.nn_arch = exp.nn_arch # -- sim method -- cfg.align_method = exp.align_method # -- sim method -- cfg.sim_method = exp.sim_method # -- combinatoric search info -- cfg.nblocks = int(exp.nblocks) cfg.patchsize = int(exp.patchsize) # -- set noise params -- nconfig = get_noise_config(cfg, exp.noise_type) cfg.noise_type = nconfig.ntype cfg.noise_params = nconfig # -- dynamics function -- cfg.dynamic_info.ppf = exp.ppf cfg.dynamic_info.total_pixels = cfg.dynamic_info.ppf * (cfg.nframes - 1) cfg.dynamic_info.nframes = exp.nframes return cfg
def setup_exp_cfg(base_cfg, exp): # -- create a copy -- cfg = copy.deepcopy(base_cfg) # -- random seed -- cfg.random_seed = exp.random_seed # -- set frame size cfg.frame_size = frame_size_from_str(exp.frame_size) cfg.dynamic_info.frame_size = cfg.frame_size # -- fix dataset -- cfg.dataset.name = exp.dataset # -- number of frames -- cfg.image_xform = exp.image_xform # -- number of frames -- cfg.nframes = int(exp.nframes) # -- bootstrapping name -- cfg.bp_type = exp.bp_type # -- batchsize -- cfg.batch_size = int(exp.batch_size) # -- combinatoric search info -- cfg.nblocks = int(exp.nblocks) cfg.patchsize = int(exp.patchsize) # -- set noise params -- nconfig = get_noise_config(cfg, exp.noise_type) cfg.noise_type = nconfig.ntype cfg.noise_params = nconfig # -- dynamics -- cfg.dynamic_info.ppf = exp.ppf cfg.dynamic_info.total_pixels = cfg.dynamic_info.ppf * (cfg.nframes - 1) cfg.dynamic_info.nframes = exp.nframes # -- some weirdness -- cfg.train_split = "all" # allow all data to be used instead of just train. return cfg
def config_setup(base_cfg,exp): # -- create a copy -- cfg = copy.deepcopy(base_cfg) # -- random seed -- cfg.random_seed = exp.random_seed # -- bss -- cfg.bss_str = exp.bss_str # -- batchsize -- cfg.batch_size = int(exp.batch_size) # -- set patchsize -- cfg.patchsize = int(exp.patchsize) # -- num of patches -- cfg.npatches = int(exp.npatches) # -- set frames -- cfg.nframes = int(exp.nframes) cfg.N = cfg.nframes # -- set number of blocks (old: neighborhood size) -- cfg.nblocks = int(exp.nblocks) cfg.nh_size = cfg.nblocks # old name # -- set noise params -- nconfig = get_noise_config(cfg,exp.noise_type) cfg.noise_type = nconfig.ntype cfg.noise_params = nconfig # -- dynamics function -- cfg.frame_size = 196 cfg.dynamic.ppf = exp.ppf cfg.dynamic.bool = True cfg.dynamic.random_eraser = False cfg.dynamic.frame_size = cfg.frame_size cfg.dynamic.total_pixels = cfg.dynamic.ppf*(cfg.nframes-1) cfg.dynamic.frames = exp.nframes return cfg
def update_noise_cfg(cfg, noise_type): nconfig = get_noise_config(cfg, noise_type) set_noise(cfg, nconfig[nconfig.ntype]) # cfg.noise_type = nconfig.ntype # cfg.noise_params = nconfig return cfg