Exemple #1
0
def test_dataset_splitting(split):
    dataset_config = get_config(CFG_MULTI_TEST).DATASET
    dataset_config.defrost()
    dataset_config.SPLIT = split

    if not PointNavDatasetV1.check_config_paths_exist(dataset_config):
        pytest.skip("Test skipped as dataset files are missing.")

    scenes = PointNavDatasetV1.get_scenes_to_load(config=dataset_config)
    assert (len(scenes) >
            0), "Expected dataset contains separate episode file per scene."

    dataset_config.CONTENT_SCENES = scenes[:PARTIAL_LOAD_SCENES]
    full_dataset = make_dataset(id_dataset=dataset_config.TYPE,
                                config=dataset_config)
    full_episodes = {(ep.scene_id, ep.episode_id)
                     for ep in full_dataset.episodes}

    dataset_config.CONTENT_SCENES = scenes[:PARTIAL_LOAD_SCENES // 2]
    split1_dataset = make_dataset(id_dataset=dataset_config.TYPE,
                                  config=dataset_config)
    split1_episodes = {(ep.scene_id, ep.episode_id)
                       for ep in split1_dataset.episodes}

    dataset_config.CONTENT_SCENES = scenes[PARTIAL_LOAD_SCENES //
                                           2:PARTIAL_LOAD_SCENES]
    split2_dataset = make_dataset(id_dataset=dataset_config.TYPE,
                                  config=dataset_config)
    split2_episodes = {(ep.scene_id, ep.episode_id)
                       for ep in split2_dataset.episodes}

    assert full_episodes == split1_episodes.union(
        split2_episodes), "Split dataset is not equal to full dataset"
    assert (len(split1_episodes.intersection(split2_episodes)) == 0
            ), "Intersection of split datasets is not the empty set"
def test_multiple_files_scene_path():
    dataset_config = get_config(CFG_MULTI_TEST).DATASET
    if not PointNavDatasetV1.check_config_paths_exist(dataset_config):
        pytest.skip("Test skipped as dataset files are missing.")
    scenes = PointNavDatasetV1.get_scenes_to_load(config=dataset_config)
    assert (
        len(scenes) > 0
    ), "Expected dataset contains separate episode file per scene."
    dataset_config.defrost()
    dataset_config.CONTENT_SCENES = scenes[:PARTIAL_LOAD_SCENES]
    dataset_config.SCENES_DIR = os.path.join(
        os.getcwd(), DEFAULT_SCENE_PATH_PREFIX
    )
    dataset_config.freeze()
    partial_dataset = make_dataset(
        id_dataset=dataset_config.TYPE, config=dataset_config
    )
    assert (
        len(partial_dataset.scene_ids) == PARTIAL_LOAD_SCENES
    ), "Number of loaded scenes doesn't correspond."
    print(partial_dataset.episodes[0].scene_id)
    assert os.path.exists(
        partial_dataset.episodes[0].scene_id
    ), "Scene file {} doesn't exist using absolute path".format(
        partial_dataset.episodes[0].scene_id
    )
def test_demo_notebook():
    config = habitat.get_config("configs/tasks/pointnav_mp3d.yaml")
    config.defrost()
    config.DATASET.SPLIT = "val"

    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
        pytest.skip(
            "Please download the Matterport3D PointNav val dataset and Matterport3D val scenes"
        )
    else:
        pytest.main(["--nbval-lax", "notebooks/habitat-api-demo.ipynb"])
Exemple #4
0
def test_single_pointnav_dataset():
    dataset_config = get_config().DATASET
    if not PointNavDatasetV1.check_config_paths_exist(dataset_config):
        pytest.skip("Test skipped as dataset files are missing.")
    scenes = PointNavDatasetV1.get_scenes_to_load(config=dataset_config)
    assert (len(scenes) >
            0), "Expected dataset contains separate episode file per scene."
    dataset = PointNavDatasetV1(config=dataset_config)
    assert len(dataset.episodes) > 0, "The dataset shouldn't be empty."
    assert (len(
        dataset.scene_ids) == 2), "The test dataset scenes number is wrong."
    check_json_serializaiton(dataset)
Exemple #5
0
def test_demo_notebook():
    config = habitat.get_config("configs/tasks/pointnav_rgbd.yaml")
    config.defrost()
    config.DATASET.SPLIT = "val"

    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
        pytest.skip("Please download the habitat test scenes")
    else:
        pytest.main([
            "--nbval-lax",
            "notebooks/relative_camera_views_transform_and_warping_demo.ipynb",
        ])
Exemple #6
0
def test_multiple_files_pointnav_dataset(cfg_path: str):
    dataset_config = get_config(cfg_path).DATASET
    if not PointNavDatasetV1.check_config_paths_exist(dataset_config):
        pytest.skip("Test skipped as dataset files are missing.")
    scenes = PointNavDatasetV1.get_scenes_to_load(config=dataset_config)
    assert (len(scenes) >
            0), "Expected dataset contains separate episode file per scene."
    dataset_config.defrost()
    dataset_config.CONTENT_SCENES = scenes
    dataset_config.freeze()
    partial_dataset = make_dataset(id_dataset=dataset_config.TYPE,
                                   config=dataset_config)
    check_json_serializaiton(partial_dataset)
Exemple #7
0
def test_multiple_files_pointnav_dataset():
    dataset_config = get_config(CFG_MULTI_TEST).DATASET
    if not PointNavDatasetV1.check_config_paths_exist(dataset_config):
        pytest.skip("Test skipped as dataset files are missing.")
    scenes = PointNavDatasetV1.get_scenes_to_load(config=dataset_config)
    assert (len(scenes) >
            0), "Expected dataset contains separate episode file per scene."
    dataset_config.defrost()
    dataset_config.CONTENT_SCENES = scenes[:PARTIAL_LOAD_SCENES]
    dataset_config.freeze()
    partial_dataset = make_dataset(id_dataset=dataset_config.TYPE,
                                   config=dataset_config)
    assert (len(partial_dataset.scene_ids) == PARTIAL_LOAD_SCENES
            ), "Number of loaded scenes doesn't correspond."
    check_json_serializaiton(partial_dataset)
def test_demo_notebook():
    config = habitat.get_config("configs/tasks/pointnav_mp3d.yaml")
    config.defrost()
    config.DATASET.SPLIT = "val"

    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
        pytest.skip(
            "Please download the Matterport3D PointNav val dataset and Matterport3D val scenes"
        )
    else:
        pytest.main(["--nbval-lax", "notebooks/habitat-api-demo.ipynb"])

        # NB: Force a gc collect run as it can take a little bit for
        # the cleanup to happen after the notebook and we get
        # a double context crash!
        gc.collect()
def test_demo_notebook():
    config = habitat.get_config("configs/tasks/pointnav_rgbd.yaml")
    config.defrost()
    config.DATASET.SPLIT = "val"

    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
        pytest.skip("Please download the habitat test scenes")
    else:
        pytest.main([
            "--nbval-lax",
            "notebooks/relative_camera_views_transform_and_warping_demo.ipynb",
        ])

        # NB: Force a gc collect run as it can take a little bit for
        # the cleanup to happen after the notebook and we get
        # a double context crash!
        gc.collect()
Exemple #10
0
def _load_test_data():
    configs = []
    datasets = []
    for i in range(NUM_ENVS):
        config = get_config(CFG_TEST)
        if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
            pytest.skip("Please download Habitat test data to data folder.")

        datasets.append(
            habitat.make_dataset(id_dataset=config.DATASET.TYPE,
                                 config=config.DATASET))

        config.defrost()
        config.SIMULATOR.SCENE = datasets[-1].episodes[0].scene_id
        if not os.path.exists(config.SIMULATOR.SCENE):
            pytest.skip("Please download Habitat test data to data folder.")
        config.freeze()
        configs.append(config)

    return configs, datasets
def test_pointnav_episode_generator():
    config = get_config(CFG_TEST)
    config.defrost()
    config.DATASET.SPLIT = "val"
    config.ENVIRONMENT.MAX_EPISODE_STEPS = 500
    config.freeze()
    if not PointNavDatasetV1.check_config_paths_exist(config.DATASET):
        pytest.skip("Test skipped as dataset files are missing.")
    with habitat.Env(config) as env:
        env.seed(config.SEED)
        random.seed(config.SEED)
        generator = pointnav_generator.generate_pointnav_episode(
            sim=env.sim,
            shortest_path_success_distance=config.TASK.SUCCESS_DISTANCE,
            shortest_path_max_steps=config.ENVIRONMENT.MAX_EPISODE_STEPS,
        )
        episodes = []
        for i in range(NUM_EPISODES):
            episode = next(generator)
            episodes.append(episode)

        for episode in pointnav_generator.generate_pointnav_episode(
            sim=env.sim,
            num_episodes=NUM_EPISODES,
            shortest_path_success_distance=config.TASK.SUCCESS_DISTANCE,
            shortest_path_max_steps=config.ENVIRONMENT.MAX_EPISODE_STEPS,
            geodesic_to_euclid_min_ratio=0,
        ):
            episodes.append(episode)

        assert len(episodes) == 2 * NUM_EPISODES
        env.episode_iterator = iter(episodes)

        for episode in episodes:
            check_shortest_path(env, episode)

        dataset = habitat.Dataset()
        dataset.episodes = episodes
        assert (
            dataset.to_json()
        ), "Generated episodes aren't json serializable."
def test_visualizations_example():
    if not PointNavDatasetV1.check_config_paths_exist(
            config=habitat.get_config().DATASET):
        pytest.skip("Please download Habitat test data to data folder.")
    visualization_examples.main()
def test_readme_example():
    if not PointNavDatasetV1.check_config_paths_exist(
            config=habitat.get_config().DATASET):
        pytest.skip("Please download Habitat test data to data folder.")
    example()
def test_shortest_path_follower_example():
    if not PointNavDatasetV1.check_config_paths_exist(
            config=habitat.get_config().DATASET):
        pytest.skip("Please download Habitat test data to data folder.")
    shortest_path_follower_example.main()
def test_register_new_sensors_and_measures():
    if not PointNavDatasetV1.check_config_paths_exist(
            config=habitat.get_config().DATASET):
        pytest.skip("Please download Habitat test data to data folder.")

    register_new_sensors_and_measures.main()
def test_new_actions():
    if not PointNavDatasetV1.check_config_paths_exist(
            config=habitat.get_config().DATASET):
        pytest.skip("Please download Habitat test data to data folder.")

    new_actions.main()