waymo-research / waymo-open-dataset

Waymo Open Dataset
https://www.waymo.com/open
Other
2.74k stars 621 forks source link

Error when running camera_segmentation_utils.decode_multi_frame_panoptic_labels_from_segmentation_labels: max() arg is an empty sequence #668

Open PradeepKadubandi opened 1 year ago

PradeepKadubandi commented 1 year ago

For some training data, the above method causes the error as mentioned.

The sample context and sequence for which this happens: context: 10724020115992582208_7660_400_7680_400 sequence: 15672339233166359051

The issue happens because all the protos in the above sequence have empty lists for local and global ids; in such a case, the code attempts to call max with an empty sequence.

This is the call stack (the relevant parts) if helpful:

    panoptic_labels, is_tracked_masks, num_cameras_covered, panoptic_label_divisor = camera_segmentation_utils.decode_multi_frame_panoptic_labels_from_segmentation_labels(
  File "/home/pkadubandi/.local/share/virtualenvs/waymo-challenge-JtwqplnD/lib/python3.9/site-packages/waymo_open_dataset/utils/camera_segmentation_utils.py", line 292, in decode_multi_frame_panoptic_labels_from_segmentation_labels
    global_id_mapping = _remap_global_ids(
  File "/home/pkadubandi/.local/share/virtualenvs/waymo-challenge-JtwqplnD/lib/python3.9/site-packages/waymo_open_dataset/utils/camera_segmentation_utils.py", line 177, in _remap_global_ids
    max_instance_id = max(global_instance_ids[sequence])
ValueError: max() arg is an empty sequence
alexzzhu commented 1 year ago

Thanks for pointing this out. The below code snippet should hopefully fix this, please let me know if you run into further issues. I'll push this to GitHub asap.

cumulative_max_instance_id = 0
global_instance_ids_offset = {}
for sequence in global_instance_ids:
  if not global_instance_ids[sequence]:
    continue
  max_instance_id = max(global_instance_ids[sequence])
  global_instance_ids_offset[sequence] = [
      inst_id + cumulative_max_instance_id
      for inst_id in global_instance_ids[sequence]
  ]
  cumulative_max_instance_id += max_instance_id

if not global_instance_ids_offset:
  return {}