def get_config( config_paths: Optional[Union[List[str], str]] = None, opts: Optional[list] = None, ) -> CN: r"""Create a unified config with default values overwritten by values from `config_paths` and overwritten by options from `opts`. Args: config_paths: List of config paths or string that contains comma separated list of config paths. opts: Config options (keys, values) in a list (e.g., passed from command line into the config. For example, `opts = ['FOO.BAR', 0.5]`. Argument can be used for parameter sweeping or quick tests. """ config = _C.clone() if config_paths: if isinstance(config_paths, str): if CONFIG_FILE_SEPARATOR in config_paths: config_paths = config_paths.split(CONFIG_FILE_SEPARATOR) else: config_paths = [config_paths] for config_path in config_paths: config.merge_from_file(config_path) config.TASK_CONFIG = get_task_config(config.BASE_TASK_CONFIG_PATH) if opts: config.CMD_TRAILING_OPTS = opts config.merge_from_list(opts) config.freeze() return config
def get_config(config_paths: Optional[Union[List[str], str]] = None, opts: Optional[list] = None, model_dir: Optional[str] = None, run_type: Optional[str] = None, overwrite: bool = False) -> CN: r"""Create a unified config with default values overwritten by values from `config_paths` and overwritten by options from `opts`. Args: config_paths: List of config paths or string that contains comma separated list of config paths. opts: Config options (keys, values) in a list (e.g., passed from command line into the config. For example, `opts = ['FOO.BAR', 0.5]`. Argument can be used for parameter sweeping or quick tests. model_dir: suffix for output dirs run_type: either train or eval overwrite: overwrite model directory """ config = merge_from_path(_C.clone(), config_paths) config.TASK_CONFIG = get_task_config( config_paths=config.BASE_TASK_CONFIG_PATH) # config_name = os.path.basename(config_paths).split('.')[0] if model_dir is not None: config.MODEL_DIR = model_dir config.TENSORBOARD_DIR = os.path.join(config.MODEL_DIR, 'tb') config.CHECKPOINT_FOLDER = os.path.join(config.MODEL_DIR, 'data') config.VIDEO_DIR = os.path.join(config.MODEL_DIR, 'video_dir') config.LOG_FILE = os.path.join(config.MODEL_DIR, 'train.log') config.EVAL_CKPT_PATH_DIR = os.path.join(config.MODEL_DIR, 'data') if opts: config.CMD_TRAILING_OPTS = opts config.merge_from_list(opts) dirs = [config.VIDEO_DIR, config.TENSORBOARD_DIR, config.CHECKPOINT_FOLDER] if run_type == 'train': # check dirs if any([os.path.exists(d) for d in dirs]): for d in dirs: if os.path.exists(d): logging.warning('{} exists'.format(d)) # if overwrite or input('Output directory already exists! Overwrite the folder? (y/n)') == 'y': if overwrite: for d in dirs: if os.path.exists(d): shutil.rmtree(d) config.TASK_CONFIG.defrost() config.TASK_CONFIG.SIMULATOR.USE_SYNC_VECENV = config.USE_SYNC_VECENV config.TASK_CONFIG.freeze() config.freeze() return config
def get_config( config_paths: Optional[Union[List[str], str]] = None, opts: Optional[list] = None, ) -> CN: r"""Create a unified config with default values overwritten by values from `config_paths` and overwritten by options from `opts`. Args: config_paths: List of config paths or string that contains comma separated list of config paths. opts: Config options (keys, values) in a list (e.g., passed from command line into the config. For example, `opts = ['FOO.BAR', 0.5]`. Argument can be used for parameter sweeping or quick tests. """ config = _C.clone() task_config_opts = [] if config_paths: if isinstance(config_paths, str): if CONFIG_FILE_SEPARATOR in config_paths: config_paths = config_paths.split(CONFIG_FILE_SEPARATOR) else: config_paths = [config_paths] for config_path in config_paths: # Read config and extract TASK_CONFIG args to add as opts with open(config_path, "r") as f: cfg = config.load_cfg(f) cfg_clone = cfg.clone() for k in list(cfg.keys()): if not k.startswith("TASK_CONFIG"): cfg_clone.pop(k) else: cfg.pop(k) task_config_opts.append(cfg_clone) config.merge_from_other_cfg(cfg) config.TASK_CONFIG = get_task_config(config.BASE_TASK_CONFIG_PATH) for tsk_opts in task_config_opts: config.merge_from_other_cfg(tsk_opts) if opts: config.CMD_TRAILING_OPTS = opts config.merge_from_list(opts) config.freeze() return config
def get_config( config_paths: Optional[Union[List[str], str]] = None, opts: Optional[list] = None, ) -> CN: r"""Create a unified config with default values overwritten by values from :ref:`config_paths` and overwritten by options from :ref:`opts`. Args: config_paths: List of config paths or string that contains comma separated list of config paths. opts: Config options (keys, values) in a list (e.g., passed from command line into the config. For example, ``opts = ['FOO.BAR', 0.5]``. Argument can be used for parameter sweeping or quick tests. """ config = _C.clone() if config_paths: if isinstance(config_paths, str): if CONFIG_FILE_SEPARATOR in config_paths: config_paths = config_paths.split(CONFIG_FILE_SEPARATOR) else: config_paths = [config_paths] for config_path in config_paths: config.merge_from_file(config_path) if opts: for k, v in zip(opts[0::2], opts[1::2]): if k == "BASE_TASK_CONFIG_PATH": config.BASE_TASK_CONFIG_PATH = v config.TASK_CONFIG = get_task_config(config.BASE_TASK_CONFIG_PATH) if opts: config.CMD_TRAILING_OPTS = config.CMD_TRAILING_OPTS + opts config.merge_from_list(config.CMD_TRAILING_OPTS) if config.NUM_PROCESSES != -1: warnings.warn( "NUM_PROCESSES is depricated and will be removed in a future version." " Use NUM_ENVIRONMENTS instead." " Overwriting NUM_ENVIRONMENTS with NUM_PROCESSES for backwards compatibility." ) config.NUM_ENVIRONMENTS = config.NUM_PROCESSES config.freeze() return config
_C.RL.DDPPO.pretrained = False # Loads just the visual encoder backbone weights _C.RL.DDPPO.pretrained_encoder = False # Whether or not the visual encoder backbone will be trained _C.RL.DDPPO.train_encoder = True # Whether or not to reset the critic linear layer _C.RL.DDPPO.reset_critic = True # ----------------------------------------------------------------------------- # ORBSLAM2 BASELINE # ----------------------------------------------------------------------------- _C.ORBSLAM2 = CN() _C.ORBSLAM2.SLAM_VOCAB_PATH = "project/habitat_baselines/slambased/data/ORBvoc.txt" _C.ORBSLAM2.SLAM_SETTINGS_PATH = "project/habitat_baselines/slambased/data/mp3d3_small1k.yaml" _C.ORBSLAM2.MAP_CELL_SIZE = 0.1 _C.ORBSLAM2.MAP_SIZE = 40 _C.ORBSLAM2.CAMERA_HEIGHT = get_task_config( ).SIMULATOR.DEPTH_SENSOR.POSITION[1] _C.ORBSLAM2.BETA = 100 _C.ORBSLAM2.H_OBSTACLE_MIN = 0.3 * _C.ORBSLAM2.CAMERA_HEIGHT _C.ORBSLAM2.H_OBSTACLE_MAX = 1.0 * _C.ORBSLAM2.CAMERA_HEIGHT _C.ORBSLAM2.D_OBSTACLE_MIN = 0.1 _C.ORBSLAM2.D_OBSTACLE_MAX = 4.0 _C.ORBSLAM2.PREPROCESS_MAP = True _C.ORBSLAM2.MIN_PTS_IN_OBSTACLE = ( get_task_config().SIMULATOR.DEPTH_SENSOR.WIDTH / 2.0) _C.ORBSLAM2.ANGLE_TH = float(np.deg2rad(15)) _C.ORBSLAM2.DIST_REACHED_TH = 0.15 _C.ORBSLAM2.NEXT_WAYPOINT_TH = 0.5 _C.ORBSLAM2.NUM_ACTIONS = 3 _C.ORBSLAM2.DIST_TO_STOP = 0.05 _C.ORBSLAM2.PLANNER_MAX_STEPS = 500 _C.ORBSLAM2.DEPTH_DENORM = get_task_config().SIMULATOR.DEPTH_SENSOR.MAX_DEPTH