From 4d7d8b32108ed177fb8fab07c46c5b51fa3ca2ac Mon Sep 17 00:00:00 2001
From: Oleksandr Maksymets <maksymets@gmail.com>
Date: Wed, 5 Feb 2020 18:47:44 -0800
Subject: [PATCH] Added doc to FloatJSON encoder, added color names, removed
 mp3d mentioning from ObjectNavDataset

---
 habitat/core/utils.py                            | 10 +++++-----
 .../datasets/object_nav/object_nav_dataset.py    | 13 +++++++++----
 habitat/utils/visualizations/maps.py             | 16 ++++++++--------
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/habitat/core/utils.py b/habitat/core/utils.py
index e5b7f15bf..ff07b9219 100644
--- a/habitat/core/utils.py
+++ b/habitat/core/utils.py
@@ -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
diff --git a/habitat/datasets/object_nav/object_nav_dataset.py b/habitat/datasets/object_nav/object_nav_dataset.py
index 79836cb4f..a595b26bd 100644
--- a/habitat/datasets/object_nav/object_nav_dataset.py
+++ b/habitat/datasets/object_nav/object_nav_dataset.py
@@ -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"]:
diff --git a/habitat/utils/visualizations/maps.py b/habitat/utils/visualizations/maps.py
index b99033319..d9ab319c6 100644
--- a/habitat/utils/visualizations/maps.py
+++ b/habitat/utils/visualizations/maps.py
@@ -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(
-- 
GitLab