MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / __getitem__

Method __getitem__

sat/data_youtube.py:78–123  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

76 self.fut_traj_list.extend(sample_traj)
77
78 def __getitem__(self, index):
79 while True:
80 video_path = self.video_list[index]
81
82 data_root, folder_name, first_frame, end_frame = video_path
83 img_list = get_frame_list(first_frame, end_frame)
84 img_list = [
85 os.path.join(data_root, folder_name, n) for n in img_list
86 ]
87 try:
88 num_frames, video_clip = self.read_img_list(img_list)
89 break
90 except Exception as e:
91 print("Broken data, skipping: {}".format(video_path))
92 index = random.randint(0, self.length - 1)
93 continue
94
95 # Add prefix
96 caption = self.captions_list[index]
97 prefix_prompt = self.prefix_prompt
98 if prefix_prompt != "":
99 prefix_prompt = prefix_prompt.strip()
100 prefix_prompt = prefix_prompt[0].upper() + prefix_prompt[1:]
101 if not prefix_prompt.endswith("."):
102 prefix_prompt += "."
103
104 if self.p_drop_action_caption > 0 and random.random() < self.p_drop_action_caption:
105 caption = prefix_prompt
106 else:
107 caption = prefix_prompt + " " + caption
108
109 # Traj
110 fut_traj = self.fut_traj_list[index]
111 fut_traj = torch.tensor(fut_traj, dtype=torch.float32) # [8, 3]
112
113 item = {
114 "with_traj": self.use_psuedo_traj,
115 "with_human_drive_token": self.with_human_drive_token,
116 "mp4": video_clip,
117 "txt": caption,
118 "num_frames": num_frames,
119 "fps": self.fps, # ? What's the use of fps?
120 "fut_traj": fut_traj, # * Placeholder, not used, no traj actually,
121 "lidar_pc_token": str(index), # * Placeholder to align with nuplan dataset
122 }
123 return item

Callers

nothing calls this directly

Calls 3

get_frame_listFunction · 0.85
read_img_listMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected