Skip to content

Commit

Permalink
add list length check to avoid error
Browse files Browse the repository at this point in the history
Signed-off-by: Shunsuke Miura <[email protected]>
  • Loading branch information
miursh committed Nov 23, 2023
1 parent 1ffee4d commit c1c5e0c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ def inspect_and_fix_t4_segment(self, segment_path: Path):
self.connect_sample_next_prev_tokens(sample_list)

# fix scene
scene_list[0]["first_sample_token"] = sample_list[0]["token"]
scene_list[0]["last_sample_token"] = sample_list[-1]["token"]
if len(scene_list) > 0 and len(sample_list) > 0:
scene_list[0]["first_sample_token"] = sample_list[0]["token"]
scene_list[0]["last_sample_token"] = sample_list[-1]["token"]

with open(segment_path / "annotation/scene.json", "w") as f:
json.dump(scene_list, f, indent=4)
Expand Down Expand Up @@ -142,6 +143,8 @@ def _fix_instance_according_to_sample_annotation(self, instance_list, sample_ann
instance["nbr_annotations"] = len(instance_annotation_list)

def connect_sample_next_prev_tokens(self, sample_list: list):
if len(sample_list) == 0:
return
sample_list = sorted(sample_list, key=lambda x: x["timestamp"])
sample_list[0]["prev"] = ""
sample_list[-1]["next"] = ""
Expand All @@ -154,6 +157,8 @@ def connect_sample_next_prev_tokens(self, sample_list: list):
cur_sample["prev"] = prev_sample["token"]

def connect_sample_data_next_prev_tokens(self, sample_data_list: list):
if len(sample_data_list) == 0:
return
sensor_list = []
[
sensor_list.append(data["calibrated_sensor_token"])
Expand Down

0 comments on commit c1c5e0c

Please sign in to comment.