Skip to content
Snippets Groups Projects
Commit 4d7d8b32 authored by Oleksandr Maksymets's avatar Oleksandr Maksymets
Browse files

Added doc to FloatJSON encoder, added color names, removed mp3d mentioning from ObjectNavDataset

parent bcfb573e
Branches
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@ import quaternion
from habitat.utils.geometry_utils import quaternion_to_list
# Internals from inner json library needed for patching functionality in
# DatasetFloatJSONEncoder.
try:
from _json import encode_basestring_ascii
except ImportError:
......@@ -108,12 +110,10 @@ def center_crop(obs, new_shape):
class DatasetFloatJSONEncoder(json.JSONEncoder):
r"""JSON Encoder that sets a float precision for a space saving purpose and
encodes ndarray and quaternion. The encoder is compatible with JSON
version 2.0.9.
"""
JSON Encoder that set float precision for space saving purpose.
"""
# Version of JSON library that encoder is compatible with.
__version__ = "2.0.9"
def default(self, object):
# JSON doesn't support numpy ndarray and quaternion
......
......@@ -25,7 +25,7 @@ class ObjectNavDatasetV1(PointNavDatasetV1):
r"""Class inherited from PointNavDataset that loads Object Navigation dataset.
"""
category_to_task_category_id: Dict[str, int]
category_to_mp3d_category_id: Dict[str, int]
category_to_scene_annotation_category_id: Dict[str, int]
episodes: List[NavigationEpisode]
content_scenes_path: str = "{data_path}/content/{scene}.json.gz"
......@@ -45,17 +45,22 @@ class ObjectNavDatasetV1(PointNavDatasetV1):
"category_to_task_category_id"
]
if "category_to_scene_annotation_category_id" in deserialized:
self.category_to_scene_annotation_category_id = deserialized[
"category_to_scene_annotation_category_id"
]
if "category_to_mp3d_category_id" in deserialized:
self.category_to_mp3d_category_id = deserialized[
self.category_to_scene_annotation_category_id = deserialized[
"category_to_mp3d_category_id"
]
assert len(self.category_to_task_category_id) == len(
self.category_to_mp3d_category_id
self.category_to_scene_annotation_category_id
)
assert set(self.category_to_task_category_id.keys()) == set(
self.category_to_mp3d_category_id.keys()
self.category_to_scene_annotation_category_id.keys()
), "category_to_task and category_to_mp3d must have the same keys"
for episode in deserialized["episodes"]:
......
......@@ -43,14 +43,14 @@ TOP_DOWN_MAP_COLORS = np.full((256, 3), 150, dtype=np.uint8)
TOP_DOWN_MAP_COLORS[10:] = cv2.applyColorMap(
np.arange(246, dtype=np.uint8), cv2.COLORMAP_JET
).squeeze(1)[:, ::-1]
TOP_DOWN_MAP_COLORS[MAP_INVALID_POINT] = [255, 255, 255]
TOP_DOWN_MAP_COLORS[MAP_VALID_POINT] = [150, 150, 150]
TOP_DOWN_MAP_COLORS[MAP_BORDER_INDICATOR] = [50, 50, 50]
TOP_DOWN_MAP_COLORS[MAP_SOURCE_POINT_INDICATOR] = [0, 0, 200]
TOP_DOWN_MAP_COLORS[MAP_TARGET_POINT_INDICATOR] = [200, 0, 0]
TOP_DOWN_MAP_COLORS[MAP_SHORTEST_PATH_COLOR] = [0, 200, 0]
TOP_DOWN_MAP_COLORS[MAP_VIEW_POINT_INDICATOR] = [245, 150, 150]
TOP_DOWN_MAP_COLORS[MAP_TARGET_BOUNDING_BOX] = [0, 175, 0]
TOP_DOWN_MAP_COLORS[MAP_INVALID_POINT] = [255, 255, 255] # White
TOP_DOWN_MAP_COLORS[MAP_VALID_POINT] = [150, 150, 150] # Light Grey
TOP_DOWN_MAP_COLORS[MAP_BORDER_INDICATOR] = [50, 50, 50] # Grey
TOP_DOWN_MAP_COLORS[MAP_SOURCE_POINT_INDICATOR] = [0, 0, 200] # Blue
TOP_DOWN_MAP_COLORS[MAP_TARGET_POINT_INDICATOR] = [200, 0, 0] # Red
TOP_DOWN_MAP_COLORS[MAP_SHORTEST_PATH_COLOR] = [0, 200, 0] # Green
TOP_DOWN_MAP_COLORS[MAP_VIEW_POINT_INDICATOR] = [245, 150, 150] # Light Red
TOP_DOWN_MAP_COLORS[MAP_TARGET_BOUNDING_BOX] = [0, 175, 0] # Green
def draw_agent(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment