Пример #1
0
def merge_sim_episode_config(
        sim_config: Config, episode: Type[Episode]
) -> Any:
    sim_config.defrost()
    # here's where the scene update happens, extract the scene name out of the path
    sim_config.SCENE = episode.scene_id
    sim_config.freeze()
    if (
            episode.start_position is not None
            and episode.start_rotation is not None
    ):
        agent_name = sim_config.AGENTS[sim_config.DEFAULT_AGENT_ID]
        agent_cfg = getattr(sim_config, agent_name)
        agent_cfg.defrost()
        agent_cfg.START_POSITION = episode.start_position
        agent_cfg.START_ROTATION = episode.start_rotation
        agent_cfg.GOAL_POSITION = episode.goals[0].position
        agent_cfg.SOUND_ID = episode.sound_id
        agent_cfg.DISTRACTOR_SOUND_ID = episode.distractor_sound_id
        agent_cfg.DISTRACTOR_POSITION_INDEX = episode.distractor_position_index
        agent_cfg.OFFSET = episode.offset
        agent_cfg.DURATION = episode.duration
        agent_cfg.IS_SET_START_STATE = True
        agent_cfg.freeze()
    return sim_config
Пример #2
0
def get_default_config():
    c = Config()
    c.INPUT_TYPE = "blind"
    c.MODEL_PATH = "data/checkpoints/blind.pth"
    c.RESOLUTION = 256
    c.HIDDEN_SIZE = 512
    c.RANDOM_SEED = 7
    c.PTH_GPU_ID = 0
    c.GOAL_SENSOR_UUID = "pointgoal"
    return c
Пример #3
0
def get_default_config() -> Config:
    c = Config()
    c.INPUT_TYPE = "rgb"
    c.MODEL_PATH = "data/checkpoints/gibson-rgb-best.pth"
    c.RESOLUTION = 256
    c.HIDDEN_SIZE = 512
    c.RANDOM_SEED = 7
    c.PTH_GPU_ID = 0
    c.GOAL_SENSOR_UUID = "pointgoal_with_gps_compass"
    return c
Пример #4
0
def merge_sim_episode_config(sim_config: Config, episode: Episode) -> Any:
    sim_config.defrost()
    sim_config.SCENE = episode.scene_id
    sim_config.freeze()
    if (episode.start_position is not None
            and episode.start_rotation is not None):
        agent_name = sim_config.AGENTS[sim_config.DEFAULT_AGENT_ID]
        agent_cfg = getattr(sim_config, agent_name)
        agent_cfg.defrost()
        agent_cfg.START_POSITION = episode.start_position
        agent_cfg.START_ROTATION = episode.start_rotation
        agent_cfg.IS_SET_START_STATE = True
        agent_cfg.freeze()
    return sim_config
Пример #5
0
    def __init__(self, config: Config) -> None:
        """Constructor

        :param config: config for the environment. Should contain id for
            simulator and ``task_name`` which are passed into ``make_sim`` and
            ``make_task``.
        :param dataset: reference to dataset for task instance level
            information. Can be defined as :py:`None` in which case
            ``_episodes`` should be populated from outside.
        """

        assert config.is_frozen(), ("Freeze the config before creating the "
                                    "environment, use config.freeze().")
        self._config = config
        self._current_episode_index = None
        self._current_episode = None
        self._scenes = config.DATASET.CONTENT_SCENES
        self._swap_building_every = config.ENVIRONMENT.ITERATOR_OPTIONS.MAX_SCENE_REPEAT_EPISODES
        self._current_scene_episode_idx = 0
        self._current_scene_idx = 0

        self._config.defrost()
        self._config.SIMULATOR.SCENE = os.path.join(
            config.DATASET.SCENES_DIR,
            'mp3d/{}/{}.glb'.format(self._scenes, self._scenes))
        self._config.freeze()

        self._sim = make_sim(id_sim=self._config.SIMULATOR.TYPE,
                             config=self._config.SIMULATOR)
Пример #6
0
 def __init__(self,
              config: Config,
              dataset: Optional[Dataset] = None) -> None:
     assert config.is_frozen(), ("Freeze the config before creating the "
                                 "environment, use config.freeze()")
     self._config = config
     self._dataset = dataset
     self._current_episode_index = None
     if self._dataset is None and config.DATASET.TYPE:
         self._dataset = make_dataset(id_dataset=config.DATASET.TYPE,
                                      config=config.DATASET)
     self._episodes = self._dataset.episodes if self._dataset else []
     self._sim = make_sim(id_sim=self._config.SIMULATOR.TYPE,
                          config=self._config.SIMULATOR)
     self._task = make_task(
         self._config.TASK.TYPE,
         task_config=self._config.TASK,
         sim=self._sim,
         dataset=dataset,
     )
     self.observation_space = SpaceDict({
         **self._sim.sensor_suite.observation_spaces.spaces,
         **self._task.sensor_suite.observation_spaces.spaces,
     })
     self.action_space = self._sim.action_space
     self._max_episode_seconds = (
         self._config.ENVIRONMENT.MAX_EPISODE_SECONDS)
     self._max_episode_steps = self._config.ENVIRONMENT.MAX_EPISODE_STEPS
     self._elapsed_steps = 0
     self._episode_start_time: Optional[float] = None
     self._episode_over = False
Пример #7
0
    def get_scenes_to_load(cls, config: Config) -> List[str]:
        r"""Return list of scene ids for which dataset has separate files with
        episodes.
        """
        assert cls.check_config_paths_exist(config)
        dataset_dir = os.path.dirname(
            config.DATA_PATH.format(split=config.SPLIT))

        cfg = config.clone()
        cfg.defrost()
        cfg.CONTENT_SCENES = []
        dataset = cls(cfg)
        has_individual_scene_files = os.path.exists(
            dataset.content_scenes_path.split("{scene}")[0].format(
                data_path=dataset_dir))
        if has_individual_scene_files:
            return cls._get_scenes_from_folder(
                content_scenes_path=dataset.content_scenes_path,
                dataset_dir=dataset_dir,
            )
        else:
            # Load the full dataset, things are not split into separate files
            cfg.CONTENT_SCENES = [ALL_SCENES_MASK]
            dataset = cls(cfg)
            return list(map(cls.scene_from_scene_path, dataset.scene_ids))
Пример #8
0
def merge_sim_episode_config(sim_config: Config,
                             episode: Type[Episode]) -> Any:
    sim_config.defrost()
    # here's where the scene update happens, extract the scene name out of the path
    sim_config.SCENE = episode.scene_id
    sim_config.freeze()
    if (episode.start_position is not None
            and episode.start_rotation is not None):
        agent_name = sim_config.AGENTS[sim_config.DEFAULT_AGENT_ID]
        agent_cfg = getattr(sim_config, agent_name)
        agent_cfg.defrost()
        agent_cfg.START_POSITION = episode.start_position
        agent_cfg.START_ROTATION = episode.start_rotation
        agent_cfg.GOAL_POSITION = episode.goals[0].position
        agent_cfg.SOUND = episode.info['sound']
        agent_cfg.IS_SET_START_STATE = True
        agent_cfg.freeze()
    return sim_config
Пример #9
0
    def __init__(self,
                 config: Config,
                 dataset: Optional[Dataset] = None) -> None:
        """Constructor

        :param config: config for the environment. Should contain id for
            simulator and ``task_name`` which are passed into ``make_sim`` and
            ``make_task``.
        :param dataset: reference to dataset for task instance level
            information. Can be defined as :py:`None` in which case
            ``_episodes`` should be populated from outside.
        """

        assert config.is_frozen(), ("Freeze the config before creating the "
                                    "environment, use config.freeze().")
        self._config = config
        self._dataset = dataset
        self._current_episode_index = None
        if self._dataset is None and config.DATASET.TYPE:
            self._dataset = make_dataset(id_dataset=config.DATASET.TYPE,
                                         config=config.DATASET)
        self._episodes = self._dataset.episodes if self._dataset else []
        self._current_episode = None
        iter_option_dict = {
            k.lower(): v
            for k, v in config.ENVIRONMENT.ITERATOR_OPTIONS.items()
        }
        self._episode_iterator = self._dataset.get_episode_iterator(
            **iter_option_dict)

        # load the first scene if dataset is present
        if self._dataset:
            assert (len(self._dataset.episodes) >
                    0), "dataset should have non-empty episodes list"
            self._config.defrost()
            self._config.SIMULATOR.SCENE = self._dataset.episodes[0].scene_id
            self._config.freeze()

        self._sim = make_sim(id_sim=self._config.SIMULATOR.TYPE,
                             config=self._config.SIMULATOR)
        self._task = make_task(
            self._config.TASK.TYPE,
            config=self._config.TASK,
            sim=self._sim,
            dataset=self._dataset,
        )
        self.observation_space = SpaceDict({
            **self._sim.sensor_suite.observation_spaces.spaces,
            **self._task.sensor_suite.observation_spaces.spaces,
        })
        self.action_space = self._task.action_space
        self._max_episode_seconds = (
            self._config.ENVIRONMENT.MAX_EPISODE_SECONDS)
        self._max_episode_steps = self._config.ENVIRONMENT.MAX_EPISODE_STEPS
        self._elapsed_steps = 0
        self._episode_start_time: Optional[float] = None
        self._episode_over = False
Пример #10
0
    def get_scenes_to_load(config: Config) -> List[str]:
        r"""Return list of scene ids for which dataset has separate files with
        episodes.
        """
        assert PointNavDatasetV1.check_config_paths_exist(config)
        dataset_dir = os.path.dirname(
            config.POINTNAVV1.DATA_PATH.format(split=config.SPLIT))

        cfg = config.clone()
        cfg.defrost()
        cfg.POINTNAVV1.CONTENT_SCENES = []
        dataset = PointNavDatasetV1(cfg)
        return PointNavDatasetV1._get_scenes_from_folder(
            content_scenes_path=dataset.content_scenes_path,
            dataset_dir=dataset_dir,
        )
Пример #11
0
    def __init__(self,
                 config: Config,
                 dataset: Optional[Dataset] = None) -> None:
        assert config.is_frozen(), ("Freeze the config before creating the "
                                    "environment, use config.freeze().")
        self._config = config
        self._dataset = dataset
        self._current_episode_index = None
        if self._dataset is None and config.DATASET.TYPE:
            self._dataset = make_dataset(id_dataset=config.DATASET.TYPE,
                                         config=config.DATASET)
        self._episodes = self._dataset.episodes if self._dataset else []
        self._current_episode = None
        iter_option_dict = {
            k.lower(): v
            for k, v in config.ENVIRONMENT.ITERATOR_OPTIONS.items()
        }
        self._episode_iterator = self._dataset.get_episode_iterator(
            **iter_option_dict)

        # load the first scene if dataset is present
        if self._dataset:
            assert (len(self._dataset.episodes) >
                    0), "dataset should have non-empty episodes list"
            self._config.defrost()
            self._config.SIMULATOR.SCENE = self._dataset.episodes[0].scene_id
            self._config.freeze()

        self._sim = make_sim(id_sim=self._config.SIMULATOR.TYPE,
                             config=self._config.SIMULATOR)
        self._task = make_task(
            self._config.TASK.TYPE,
            task_config=self._config.TASK,
            sim=self._sim,
            dataset=self._dataset,
        )
        self.observation_space = SpaceDict({
            **self._sim.sensor_suite.observation_spaces.spaces,
            **self._task.sensor_suite.observation_spaces.spaces,
        })
        self.action_space = self._sim.action_space
        self._max_episode_seconds = (
            self._config.ENVIRONMENT.MAX_EPISODE_SECONDS)
        self._max_episode_steps = self._config.ENVIRONMENT.MAX_EPISODE_STEPS
        self._elapsed_steps = 0
        self._episode_start_time: Optional[float] = None
        self._episode_over = False
Пример #12
0
    def get_scenes_to_load(config: Config) -> List[str]:
        r"""Return list of scene ids for which dataset has separate files with
        episodes.
        """
        assert AudioNavDataset.check_config_paths_exist(config), \
            (config.DATA_PATH.format(version=config.VERSION, split=config.SPLIT), config.SCENES_DIR)
        dataset_dir = os.path.dirname(
            config.DATA_PATH.format(version=config.VERSION, split=config.SPLIT)
        )

        cfg = config.clone()
        cfg.defrost()
        cfg.CONTENT_SCENES = []
        dataset = AudioNavDataset(cfg)
        return AudioNavDataset._get_scenes_from_folder(
            content_scenes_path=dataset.content_scenes_path,
            dataset_dir=dataset_dir,
        )
Пример #13
0
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

from habitat.config import Config as CN  # type: ignore

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","

# -----------------------------------------------------------------------------
# Config definition
# -----------------------------------------------------------------------------
_C = CN()
_C.SEED = 100
# -----------------------------------------------------------------------------
# ENVIRONMENT
# -----------------------------------------------------------------------------
_C.ENVIRONMENT = CN()
_C.ENVIRONMENT.MAX_EPISODE_STEPS = 1000
_C.ENVIRONMENT.MAX_EPISODE_SECONDS = 10000000
_C.ENVIRONMENT.ITERATOR_OPTIONS = CN()
_C.ENVIRONMENT.ITERATOR_OPTIONS.CYCLE = True
_C.ENVIRONMENT.ITERATOR_OPTIONS.SHUFFLE = True
_C.ENVIRONMENT.ITERATOR_OPTIONS.GROUP_BY_SCENE = True
_C.ENVIRONMENT.ITERATOR_OPTIONS.NUM_EPISODE_SAMPLE = -1
_C.ENVIRONMENT.ITERATOR_OPTIONS.MAX_SCENE_REPEAT_EPISODES = -1
_C.ENVIRONMENT.ITERATOR_OPTIONS.MAX_SCENE_REPEAT_STEPS = int(1e4)
_C.ENVIRONMENT.ITERATOR_OPTIONS.STEP_REPETITION_RANGE = 0.2
Пример #14
0
    def __init__(self,
                 config: Config,
                 dataset: Optional[Dataset] = None) -> None:
        """Constructor. Mimics the :ref:`Env` constructor.

        Args:
            :param config: config for the environment. Should contain id for
            simulator and ``task_name`` for each task, which are passed into ``make_sim`` and
            ``make_task``.
            :param dataset: reference to dataset used for first task instance level
            information. Can be defined as :py:`None` in which case
            dataset will be built using ``make_dataset`` and ``config``.
        """
        # let superclass instantiate current task by merging first task in TASKS to TASK
        if len(config.MULTI_TASK.TASKS):
            logger.info(
                "Overwriting config.TASK ({}) with first entry in config.MULTI_TASK.TASKS ({})."
                .format(config.TASK.TYPE, config.MULTI_TASK.TASKS[0].TYPE))
            config.defrost()
            config.TASK.merge_from_other_cfg(config.MULTI_TASK.TASKS[0])
            config.freeze()
            # TASKS[0] dataset has higher priority over default one (if specified), instatiate it before
            if dataset is None and config.MULTI_TASK.TASKS[0].DATASET.TYPE:
                dataset = make_dataset(
                    id_dataset=config.MULTI_TASK.TASKS[0].DATASET.TYPE,
                    config=config.MULTI_TASK.TASKS[0].DATASET,
                )
        # initialize first task leveraging Env
        super().__init__(config, dataset=dataset)
        # instatiate other tasks
        self._tasks = [self._task]
        self._curr_task_idx = 0
        # keep each tasks episode iterator to avoid re-creation
        self._episode_iterators = [self._episode_iterator]
        for task in config.MULTI_TASK.TASKS[1:]:
            self._tasks.append(
                make_task(
                    task.TYPE,
                    config=task,
                    sim=self._sim,
                    # each task gets its dataset
                    dataset=make_dataset(  # TODO: lazy make_dataset support
                        id_dataset=task.DATASET.TYPE,
                        config=task.DATASET),
                ))
            # get task episode iterator
            iter_option_dict = {
                k.lower(): v
                for k, v in task.EPISODE_ITERATOR_OPTIONS.items()
            }
            iter_option_dict["seed"] = self._config.SEED
            task_ep_iterator: EpisodeIterator = self._tasks[
                -1]._dataset.get_episode_iterator(**iter_option_dict)
            self._episode_iterators.append(task_ep_iterator)
        # episode counter
        self._eps_counter = -1
        self._cumulative_steps_counter = 0
        # when and how to change task is defined here
        self._task_sampling_behavior = (
            config.MULTI_TASK.TASK_ITERATOR.TASK_SAMPLING)
        self._change_task_behavior = (
            config.MULTI_TASK.TASK_ITERATOR.TASK_CHANGE_TIMESTEP)
        # custom task label can be specified
        self._curr_task_label = self._task._config.get("TASK_LABEL",
                                                       self._curr_task_idx)
        # add task_idx to observation space
        self.observation_space = spaces.Dict({
            **self._sim.sensor_suite.observation_spaces.spaces,
            **self._task.sensor_suite.observation_spaces.spaces,
            "task_idx":
            spaces.Discrete(len(self._tasks)),
        })
Пример #15
0
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

from habitat.config import Config as CN  # type: ignore

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","

# -----------------------------------------------------------------------------
# Config definition
# -----------------------------------------------------------------------------
_C = CN()
_C.SEED = 100
# -----------------------------------------------------------------------------
# ENVIRONMENT
# -----------------------------------------------------------------------------
_C.ENVIRONMENT = CN()
_C.ENVIRONMENT.MAX_EPISODE_STEPS = 1000
_C.ENVIRONMENT.MAX_EPISODE_SECONDS = 10000000
# -----------------------------------------------------------------------------
# TASK
# -----------------------------------------------------------------------------
_C.TASK = CN()
_C.TASK.TYPE = "Nav-v0"
_C.TASK.SUCCESS_DISTANCE = 0.2
_C.TASK.SENSORS = []
_C.TASK.MEASUREMENTS = []
Пример #16
0
import os
import logging
import shutil

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN
import habitat

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.SEED = 0
_C.BASE_TASK_CONFIG_PATH = "configs/tasks/pointgoal.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "AVNavTrainer"
_C.ENV_NAME = "AudioNavRLEnv"
_C.SIMULATOR_GPU_ID = 0
_C.TORCH_GPU_ID = 0
_C.VIDEO_OPTION = ["disk", "tensorboard"]
_C.VISUALIZATION_OPTION = ["top_down_map"]
_C.TENSORBOARD_DIR = "tb"
_C.VIDEO_DIR = "video_dir"
_C.TEST_EPISODE_COUNT = 2
_C.EVAL_CKPT_PATH_DIR = "data/checkpoints"  # path to ckpt or path to ckpts dir
_C.NUM_PROCESSES = 16
Пример #17
0
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.BASE_TASK_CONFIG_PATH = "configs/tasks/vln_r2r.yaml"
_C.BERT_CONFIG = "/home/erick/Research/vln/libs/habitat/habitat-api/habitat_baselines/vln/config/bert_base_6layer_6connect.json"
_C.BERT_GPU = 2
_C.BERT_PRE_TRAINED_MODEL = "bert-base-uncased"
_C.MAX_TOKEN_LENGTH = 128
_C.TOKENIZER = "BertTokenizer"
_C.DETECTRON2_GPU = 1
_C.DETECTRON2_MODEL = 'BUA_R_101_C4_MAX' #"IS_R_101_C4_3x"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "vln"
_C.ENV_NAME = "VLNRLEnv"
_C.SIMULATOR_GPU_ID = 3
_C.TORCH_GPU_ID = 4
_C.VIDEO_OPTION = ["disk", "tensorboard"]
Пример #18
0
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

import os
from typing import Optional

from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"

# -----------------------------------------------------------------------------
# Config definition
# -----------------------------------------------------------------------------
_C = CN()
_C.SEED = 100
# -----------------------------------------------------------------------------
# BASELINES
# -----------------------------------------------------------------------------
_C.BASELINE = CN()
# -----------------------------------------------------------------------------
# REINFORCEMENT LEARNING (RL)
# -----------------------------------------------------------------------------
_C.BASELINE.RL = CN()
_C.BASELINE.RL.SUCCESS_REWARD = 10.0
_C.BASELINE.RL.SLACK_REWARD = -0.01
# -----------------------------------------------------------------------------


def cfg(config_file: Optional[str] = None,
Пример #19
0
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.MULTIPLY_SCENES = False
_C.BASE_TASK_CONFIG_PATH = "configs/tasks/explore_replica.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.SHARED_DATA = []  # HACKY share stuff
_C.SHARED_SIZES = []  # HACKY share stuff
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "ppo"
_C.ENV_NAME = "NavRLEnv"
_C.SIMULATOR_GPU_ID = 0
_C.TORCH_GPU_ID = 0
_C.VIDEO_OPTION = ["disk", "tensorboard"]
_C.VIDEO_OPTION_INTERVAL = 10
_C.TENSORBOARD_DIR = "tb"
_C.VIDEO_DIR = "video_dir"
_C.TEST_EPISODE_COUNT = 36
Пример #20
0
def get_default_r2r_v1_config(split: str = "val"):
    config = Config()
    config.name = "VLNR2R-v1"
    config.DATA_PATH = "data/datasets/vln/r2r/v1/{split}/R2R_{split}.json.gz"
    config.SPLIT = split
    return config
Пример #21
0
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import math
import numpy as np

from habitat_extensions import get_extended_config as get_task_config
from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.PYT_RANDOM_SEED = 123
_C.BASE_TASK_CONFIG_PATH = "habitat_extensions/config/exploration_gibson.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "occant_exp"
_C.ENV_NAME = "ExpRLEnv"
_C.SIMULATOR_GPU_ID = 0
_C.SIMULATOR_GPU_IDS = []  # Assign specific GPUs to simulator
_C.TORCH_GPU_ID = 0
_C.VIDEO_OPTION = ["disk", "tensorboard"]
_C.TENSORBOARD_DIR = "tb"
_C.VIDEO_DIR = "video_dir"
_C.TEST_EPISODE_COUNT = -1
_C.EVAL_CKPT_PATH_DIR = "data/checkpoints"  # path to ckpt or path to ckpts dir
_C.EVAL_PREV_CKPT_ID = -1  # The evaluation starts at (this value + 1)th ckpt
Пример #22
0
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN
import os

DEFAULT_CONFIG_DIR = "IL_configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.VERSION = 'base'
_C.AGENT_TASK = 'search'
_C.BASE_TASK_CONFIG_PATH = "IL_configs/tasks/pointnav.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "ppo"
_C.ENV_NAME = "NavRLEnv"
_C.SIMULATOR_GPU_ID = 0
_C.TORCH_GPU_ID = 0
_C.VIDEO_OPTION = ["disk", "tensorboard"]
_C.TENSORBOARD_DIR = "logs/"
_C.VIDEO_DIR = "data/video_dir"
_C.TEST_EPISODE_COUNT = 2
_C.EVAL_CKPT_PATH_DIR = "data/eval_checkpoints"  # path to ckpt or path to ckpts dir
_C.NUM_PROCESSES = 16
Пример #23
0
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# Config definition
# -----------------------------------------------------------------------------
_C = CN()
_C.BASE_TASK_CONFIG_PATH = "configs/tasks/pointnav.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = ""  # store command line options"
# -----------------------------------------------------------------------------
# TRAINER ALGORITHMS
# -----------------------------------------------------------------------------
_C.TRAINER = CN()
_C.TRAINER.TRAINER_NAME = "ppo"
# -----------------------------------------------------------------------------
# REINFORCEMENT LEARNING (RL)
# -----------------------------------------------------------------------------
_C.TRAINER.RL = CN()
_C.TRAINER.RL.SUCCESS_REWARD = 10.0
_C.TRAINER.RL.SLACK_REWARD = -0.01
# -----------------------------------------------------------------------------
Пример #24
0
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

import numpy as np

from habitat import get_config as get_task_config
from habitat.config import Config as CN

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","
# -----------------------------------------------------------------------------
# EXPERIMENT CONFIG
# -----------------------------------------------------------------------------
_C = CN()
_C.BASE_TASK_CONFIG_PATH = "configs/tasks/pointnav.yaml"
_C.TASK_CONFIG = CN()  # task_config will be stored as a config node
_C.CMD_TRAILING_OPTS = []  # store command line options as list of strings
_C.TRAINER_NAME = "ppo"
_C.ENV_NAME = "NavRLEnv"
_C.SIMULATOR_GPU_ID = 0
_C.TORCH_GPU_ID = 0
_C.VIDEO_OPTION = ["disk", "tensorboard"]
_C.TENSORBOARD_DIR = "tb"
_C.VIDEO_DIR = "video_dir"
_C.TEST_EPISODE_COUNT = 2
_C.EVAL_CKPT_PATH_DIR = "data/checkpoints"  # path to ckpt or path to ckpts dir
_C.NUM_PROCESSES = 16
_C.SENSORS = ["RGB_SENSOR", "DEPTH_SENSOR"]
_C.CHECKPOINT_FOLDER = "data/checkpoints"
Пример #25
0
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

from typing import List, Optional, Union

from habitat.config import Config as CN  # type: ignore

DEFAULT_CONFIG_DIR = "configs/"
CONFIG_FILE_SEPARATOR = ","

# -----------------------------------------------------------------------------
# Config definition
# -----------------------------------------------------------------------------
_C = CN()
_C.SEED = 100
# -----------------------------------------------------------------------------
# ENVIRONMENT
# -----------------------------------------------------------------------------
_C.ENVIRONMENT = CN()
_C.ENVIRONMENT.MAX_EPISODE_STEPS = 1000
_C.ENVIRONMENT.MAX_EPISODE_SECONDS = 10000000
_C.ENVIRONMENT.ITERATOR_OPTIONS = CN()
_C.ENVIRONMENT.ITERATOR_OPTIONS.CYCLE = True
_C.ENVIRONMENT.ITERATOR_OPTIONS.SHUFFLE = True
_C.ENVIRONMENT.ITERATOR_OPTIONS.GROUP_BY_SCENE = False
_C.ENVIRONMENT.ITERATOR_OPTIONS.NUM_EPISODE_SAMPLE = -1
_C.ENVIRONMENT.ITERATOR_OPTIONS.MAX_SCENE_REPEAT = -1

_C.ENVIRONMENT.OVERRIDE_RAND_GOAL = CN()
Пример #26
0
def get_default_mp3d_v1_config(split: str = "val"):
    config = Config()
    config.name = "MP3DEQA-v1"
    config.DATA_PATH = "data/datasets/eqa/mp3d/v1/{split}.json.gz"
    config.SPLIT = split
    return config
Пример #27
0
    def __init__(self, config: Config) -> None:
        """Constructor

        :param config: config for the environment. Should contain id for
            simulator and ``task_name`` which are passed into ``make_sim`` and
            ``make_task``.
        :param dataset: reference to dataset for task instance level
            information. Can be defined as :py:`None` in which case
            ``_episodes`` should be populated from outside.
        """

        assert config.is_frozen(), ("Freeze the config before creating the "
                                    "environment, use config.freeze().")
        self._config = config
        self._current_episode_index = None
        self._current_episode = None
        iter_option_dict = {
            k.lower(): v
            for k, v in config.ENVIRONMENT.ITERATOR_OPTIONS.items()
        }

        self._scenes = config.DATASET.CONTENT_SCENES
        self._swap_building_every = config.ENVIRONMENT.ITERATOR_OPTIONS.MAX_SCENE_REPEAT_EPISODES
        print('[HabitatEnv] Total {} scenes : '.format(len(self._scenes)),
              self._scenes)
        print('[HabitatEnv] swap building every', self._swap_building_every)
        self._current_scene_episode_idx = 0
        self._current_scene_idx = 0

        self._config.defrost()
        if 'mp3d' in config.DATASET.DATA_PATH:
            self._config.SIMULATOR.SCENE = os.path.join(
                config.DATASET.SCENES_DIR,
                'mp3d/{}/{}.glb'.format(self._scenes[0], self._scenes[0]))
        else:
            self._config.SIMULATOR.SCENE = os.path.join(
                config.DATASET.SCENES_DIR,
                'gibson_habitat/{}.glb'.format(self._scenes[0]))
            if not os.path.exists(self._config.SIMULATOR.SCENE):
                self._config.SIMULATOR.SCENE = os.path.join(
                    self._config.DATASET.SCENES_DIR,
                    'gibson_more/{}.glb'.format(self._scenes[0]))
        self._config.freeze()

        self._sim = make_sim(id_sim=self._config.SIMULATOR.TYPE,
                             config=self._config.SIMULATOR)
        self._task = make_task(self._config.TASK.TYPE,
                               config=self._config.TASK,
                               sim=self._sim)
        self.observation_space = SpaceDict({
            **self._sim.sensor_suite.observation_spaces.spaces,
            **self._task.sensor_suite.observation_spaces.spaces,
        })
        self.action_space = self._task.action_space
        self._max_episode_seconds = (
            self._config.ENVIRONMENT.MAX_EPISODE_SECONDS)
        self._max_episode_steps = self._config.ENVIRONMENT.MAX_EPISODE_STEPS
        self._elapsed_steps = 0
        self._episode_start_time: Optional[float] = None
        self._episode_over = False

        #TODO listup demonstration data
        self._episode_dataset = {}