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

Class YouTubeDataset

sat/data_youtube.py:12–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10from data_share import SharedDataset
11
12class YouTubeDataset(SharedDataset):
13
14 def __init__(self,
15 merge_static=False,
16 exclude_highly_static=False,
17 use_psuedo_traj=False,
18 **kwargs):
19 """
20 skip_frms_num: ignore the first and the last xx frames, avoiding transitions.
21 """
22
23 self.merge_static = merge_static
24 self.exclude_highly_static = exclude_highly_static
25 self.use_psuedo_traj = use_psuedo_traj
26 super(YouTubeDataset, self).__init__(**kwargs)
27
28
29
30 # * Repeat data here
31 def load_data_json(self, data_json, n_subset=None, ind_subset=None):
32 infos = load_json(data_json)
33 data_root = infos['meta']['data_root']
34 clip_infos = infos['clips']
35 if n_subset is not None and ind_subset is not None:
36 print("Using subset: {}/{}".format(ind_subset, n_subset))
37 length_per_subset = math.ceil(len(clip_infos) / n_subset)
38 start_ind = ind_subset * length_per_subset
39 end_ind = (ind_subset + 1) * length_per_subset
40 clip_infos = clip_infos[start_ind:end_ind]
41
42 for clip in tqdm(clip_infos):
43
44 sample_path_tuple = (data_root, clip['folder_name'], clip['first_frame'], clip['end_frame'])
45 raw_caption = clip.get("flow_direction", "") # include static and highly static
46
47 if self.use_psuedo_traj:
48 fut_traj = clip[self.traj_key][:self.n_fut_traj_points]
49 else:
50 fut_traj = torch.zeros((8, 3))
51
52 if self.exclude_highly_static and "Highly_Static" in raw_caption:
53 continue
54
55 sample_caption = raw_caption
56 if self.merge_static and "Static" in sample_caption:
57 sample_caption = "Moving_Forward" # merging static and highly static to forward
58
59 sample_caption = sample_caption.replace("_", " ").lower() # * MINOR FIX: Converting action to lowercase
60 sample_caption = sample_caption[0].upper() + sample_caption[1:]
61 if not sample_caption.endswith("."):
62 sample_caption += "."
63
64 if self.n_repeat_of_actions is not None:
65 n_repeat = self.n_repeat_of_actions[raw_caption]
66 else:
67 n_repeat = 1
68
69 # * Repeat to achieve data weighting

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected