Meehai commited on
Commit
79f2774
·
1 Parent(s): f7296c7

fix broadcasting issue

Browse files
scripts/semantic_mapper/semantic_mapper.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
scripts/semantic_mapper/semantic_mapper.py CHANGED
@@ -275,7 +275,7 @@ class BuildingsFromM2FDepth(BinaryMapper, NpIORepresentation):
275
  buildings = super().merge_fn(dep_data[0:-1])
276
  depth = dep_data[-1]
277
  thr = 0.3 # np.percentile(depth.numpy(), 0.8)
278
- buildings_depth = buildings * (depth <= thr)
279
  return self.disk_to_memory_fmt(buildings_depth.astype(bool))
280
 
281
  class SafeLandingAreas(BinaryMapper, NpIORepresentation):
@@ -318,7 +318,7 @@ class SafeLandingAreas(BinaryMapper, NpIORepresentation):
318
  def merge_fn(self, dep_data: list[MemoryData]) -> MemoryData:
319
  depth, normals = dep_data[0:2]
320
  v1, v2, v3 = normals.transpose(2, 0, 1)
321
- where_safe = (v2 > 0.8) * ((v1 + v3) < 1.2) * (depth <= 0.9)
322
  if self.include_semantics:
323
  mapi1, coco, mapi2 = dep_data[2:5]
324
  mapi1, coco, mapi2 = mapi1.argmax(-1), coco.argmax(-1), mapi2.argmax(-1)
@@ -477,12 +477,12 @@ if __name__ == "__main__":
477
  statistics=statistics)
478
  orig_task_names = list(reader.task_types.keys())
479
 
480
- # new_tasks = get_new_semantic_mapped_tasks()
481
- # for task_name in reader.task_names:
482
- # if task_name not in orig_task_names:
483
- # reader.remove_task(task_name)
484
- # for new_task in new_tasks.values():
485
- # reader.add_task(new_task, overwrite=True)
486
 
487
  print("== Random loaded item ==")
488
  ixs = np.random.permutation(range(len(reader))).tolist()
 
275
  buildings = super().merge_fn(dep_data[0:-1])
276
  depth = dep_data[-1]
277
  thr = 0.3 # np.percentile(depth.numpy(), 0.8)
278
+ buildings_depth = buildings * (depth[..., 0] <= thr)
279
  return self.disk_to_memory_fmt(buildings_depth.astype(bool))
280
 
281
  class SafeLandingAreas(BinaryMapper, NpIORepresentation):
 
318
  def merge_fn(self, dep_data: list[MemoryData]) -> MemoryData:
319
  depth, normals = dep_data[0:2]
320
  v1, v2, v3 = normals.transpose(2, 0, 1)
321
+ where_safe = (v2 > 0.8) * ((v1 + v3) < 1.2) * (depth[..., 0] <= 0.9)
322
  if self.include_semantics:
323
  mapi1, coco, mapi2 = dep_data[2:5]
324
  mapi1, coco, mapi2 = mapi1.argmax(-1), coco.argmax(-1), mapi2.argmax(-1)
 
477
  statistics=statistics)
478
  orig_task_names = list(reader.task_types.keys())
479
 
480
+ new_tasks = get_new_semantic_mapped_tasks()
481
+ for task_name in reader.task_names:
482
+ if task_name not in orig_task_names:
483
+ reader.remove_task(task_name)
484
+ for new_task in new_tasks.values():
485
+ reader.add_task(new_task, overwrite=True)
486
 
487
  print("== Random loaded item ==")
488
  ixs = np.random.permutation(range(len(reader))).tolist()