Construct the video loader.
(self)
| 87 | self.rand_erase = True |
| 88 | |
| 89 | def _construct_loader(self): |
| 90 | """ |
| 91 | Construct the video loader. |
| 92 | """ |
| 93 | path_to_file = os.path.join( |
| 94 | self.cfg.DATA.PATH_TO_DATA_DIR, "{}.csv".format(self.mode) |
| 95 | ) |
| 96 | assert g_pathmgr.exists(path_to_file), "{} dir not found".format( |
| 97 | path_to_file |
| 98 | ) |
| 99 | |
| 100 | self._path_to_videos = [] |
| 101 | self._labels = [] |
| 102 | self._spatial_temporal_idx = [] |
| 103 | with g_pathmgr.open(path_to_file, "r") as f: |
| 104 | for clip_idx, path_label in enumerate(f.read().splitlines()): |
| 105 | assert ( |
| 106 | len(path_label.split(self.cfg.DATA.PATH_LABEL_SEPARATOR)) |
| 107 | == 2 |
| 108 | ) |
| 109 | path, label = path_label.split( |
| 110 | self.cfg.DATA.PATH_LABEL_SEPARATOR |
| 111 | ) |
| 112 | for idx in range(self._num_clips): |
| 113 | self._path_to_videos.append( |
| 114 | os.path.join(self.cfg.DATA.PATH_PREFIX, path) |
| 115 | ) |
| 116 | self._labels.append(int(label)) |
| 117 | self._spatial_temporal_idx.append(idx) |
| 118 | self._video_meta[clip_idx * self._num_clips + idx] = {} |
| 119 | assert ( |
| 120 | len(self._path_to_videos) > 0 |
| 121 | ), "Failed to load MiT split {} from {}".format( |
| 122 | self._split_idx, path_to_file |
| 123 | ) |
| 124 | logger.info( |
| 125 | "Constructing MiT dataloader (size: {}) from {}".format( |
| 126 | len(self._path_to_videos), path_to_file |
| 127 | ) |
| 128 | ) |
| 129 | |
| 130 | def __getitem__(self, index): |
| 131 | """ |