Пример #1
0
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
    :p:`config_paths` and overwritten by options from :p:`opts`.

    :param config_paths: List of config paths or string that contains comma
        separated list of config paths.
    :param opts: Config options (keys, values) in a list (e.g., passed from
        command line into the config. For example,
        :py:`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:
        config.merge_from_list(opts)

    config.freeze()
    return config
Пример #2
0
def update_config(config: yacs.config.CfgNode) -> None:
    if config.mode == 'MPIIGaze':
        _set_eye_default_camera(config)
    elif config.mode == 'MPIIFaceGaze':
        _set_face_default_camera(config)
    else:
        raise ValueError
    _update_camera_config(config)
    _download_dlib_pretrained_model(config)
    _expanduser_all(config)
    _check_path_all(config)

    config.freeze()
Пример #3
0
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
    :p:`config_paths` and overwritten by options from :p:`opts`.

    :param config_paths: List of config paths or string that contains comma
        separated list of config paths.
    :param opts: Config options (keys, values) in a list (e.g., passed from
        command line into the config. For example,
        :py:`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:
        config.merge_from_list(opts)
    # multi-task handling
    # list of tasks to list of config nodes, levaraging `TASK` default values
    tasks = []
    for task in config.MULTI_TASK.TASKS:
        # get default values
        t = _C.TASK.clone()
        task = CN(init_dict=task)

        # each task can now have a different dataset, if unspecified the global one is used
        t.DATASET = config.DATASET.clone()
        # same thing for the episode iterator
        t.EPISODE_ITERATOR_OPTIONS = (
            config.ENVIRONMENT.ITERATOR_OPTIONS.clone()
        )
        t.merge_from_other_cfg(task)
        tasks.append(t)
    config.MULTI_TASK.TASKS = tasks
    config.freeze()
    return config
Пример #4
0
def load_config() -> yacs.config.CfgNode:
    parser = argparse.ArgumentParser()
    parser.add_argument('--config', type=str)
    parser.add_argument('options', default=None, nargs=argparse.REMAINDER)
    args = parser.parse_args()

    config = get_default_config()
    if args.config is not None:
        config.merge_from_file(args.config)
    config.merge_from_list(args.options)
    if not torch.cuda.is_available():
        config.device = 'cpu'
        config.train.train_dataloader.pin_memory = False
        config.train.val_dataloader.pin_memory = False
        config.test.dataloader.pin_memory = False
    config.freeze()
    return config
Пример #5
0
def update_config(config: yacs.config.CfgNode) -> None:
    _update_camera_config(config)
    _download_dlib_pretrained_model(config)
    _expanduser_all(config)
    _check_path_all(config)
    config.freeze()