Skip to content

Commit be110f3

Browse files
Feature/drop seaborn (#79)
* use built-in colormap in python * fully drop room colors in mp3d
1 parent 868c82f commit be110f3

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ requires-python = ">=3.8"
1212
dependencies = [
1313
"click",
1414
"numpy",
15-
"seaborn",
1615
"shapely",
1716
"zmq",
1817
]

python/spark_dsg/mp3d.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from typing import Any, Dict, List
3939

4040
import numpy as np
41-
import seaborn as sns
4241
import shapely.geometry
4342
import shapely.ops
4443

@@ -236,10 +235,9 @@ def get_id(self):
236235
"""Get a NodeSymbol using the original region index from the mp3d file."""
237236
return NodeSymbol("R", self._index)
238237

239-
def get_attrs(self, color):
238+
def get_attrs(self):
240239
"""Get suitable room node attributes for inclusion in a scene graph."""
241240
attrs = RoomNodeAttributes()
242-
attrs.color = color
243241
attrs.name = str(NodeSymbol("R", self._index))
244242
attrs.position = self._pos
245243
attrs.last_update_time_ns = 0
@@ -397,12 +395,11 @@ def expand_rooms(G_old, verbose=False):
397395
def repartition_rooms(
398396
G_prev,
399397
mp3d_info,
400-
angle_deg=-90.0,
401-
min_iou_threshold=0.0,
402-
colors=None,
403-
verbose=False,
404-
eps=0.0,
405-
z_eps=0.0,
398+
angle_deg: float = -90.0,
399+
min_iou_threshold: float = 0.0,
400+
verbose: bool = False,
401+
eps: float = 0.0,
402+
z_eps: float = 0.0,
406403
):
407404
"""
408405
Create a copy of the DSG with ground-truth room nodes.
@@ -412,7 +409,6 @@ def repartition_rooms(
412409
mp3d_info (Dict[str, List[Dict[Str, Any]]]): Parsed house file information
413410
angle_deg (float): Degrees to rotate the parsed rooms
414411
min_iou_threshold (float): Minimum intersection over union for valid rooms
415-
colors (Optional[List[Iterable[float]]]): Optional colormap to assign to rooms
416412
verbose (bool): Print information about repartition process
417413
418414
Returns:
@@ -426,17 +422,12 @@ def repartition_rooms(
426422
G.remove_node(i)
427423

428424
new_rooms = get_rooms_from_mp3d_info(mp3d_info, angle_deg)
429-
430-
if colors is None:
431-
colors = sns.color_palette("husl", len(new_rooms))
432-
433425
buildings = [node.id.value for node in G.get_layer(DsgLayers.BUILDINGS).nodes]
434426

435427
# add new room nodes and connect them to building node
436428
room_id_to_gt_index = dict() # map room node id in dsg to index in new_rooms
437429
for index, room in enumerate(new_rooms):
438-
color = np.array([int(255 * c) for c in colors[index % len(colors)]][:3])
439-
attrs = room.get_attrs(color)
430+
attrs = room.get_attrs()
440431

441432
room_id = room.get_id()
442433
G.add_node(DsgLayers.ROOMS, room_id.value, attrs)
@@ -558,6 +549,7 @@ def add_gt_room_label(
558549
# check whether hydra room position is inside the ground-truth room
559550
if not mp3d_room.pos_on_same_floor(room.attributes.position):
560551
continue
552+
561553
intersection_area = xy_polygon.intersection(hydra_polygon).area
562554
union_area = xy_polygon.union(hydra_polygon).area
563555
intersection_over_union.append((idx, intersection_area / union_area))

python/spark_dsg/networkx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@
3535
"""Conversion from spark_dsg to networkx."""
3636

3737
import importlib
38-
import logging
38+
import warnings
3939

4040

4141
def _get_networkx():
4242
networkx = None
4343
try:
4444
networkx = importlib.import_module("networkx")
4545
except ImportError:
46-
logging.warning("networkx not found. conversion disabled")
46+
warnings.warn("Coud not find networkx! Conversion disabled!")
4747

4848
return networkx
4949

0 commit comments

Comments
 (0)