Construct the video loader.
(self)
| 79 | self.rand_erase = True |
| 80 | |
| 81 | def _construct_loader(self): |
| 82 | """ |
| 83 | Construct the video loader. |
| 84 | """ |
| 85 | path_to_file = os.path.join( |
| 86 | self.cfg.DATA.PATH_TO_DATA_DIR, |
| 87 | self.cfg.DATA.LABEL_PATH_TEMPLATE.format( |
| 88 | "train" if self.mode == "train" else "validation" |
| 89 | ), |
| 90 | ) |
| 91 | tmp = [x.strip().split(' ') for x in open(path_to_file)] |
| 92 | self._path_to_videos = list() |
| 93 | self._labels = list() |
| 94 | for item in tmp: |
| 95 | path = item[0] |
| 96 | num_frames = int(item[1]) |
| 97 | label = int(item[2]) |
| 98 | # path_list = list() |
| 99 | # for i in range(num_frames): |
| 100 | # path_list.append(os.path.join( |
| 101 | # self.cfg.DATA.PATH_PREFIX, |
| 102 | # path, |
| 103 | # self.cfg.DATA.IMAGE_TEMPLATE.format(i+1) |
| 104 | # )) |
| 105 | # 0: path, 1: num_frames |
| 106 | self._path_to_videos.append([path, num_frames]) |
| 107 | self._labels.append(label) |
| 108 | |
| 109 | # Extend self when self._num_clips > 1 (during testing). |
| 110 | self._path_to_videos = list( |
| 111 | chain.from_iterable( |
| 112 | [[x] * self._num_clips for x in self._path_to_videos] |
| 113 | ) |
| 114 | ) |
| 115 | self._labels = list( |
| 116 | chain.from_iterable([[x] * self._num_clips for x in self._labels]) |
| 117 | ) |
| 118 | self._spatial_temporal_idx = list( |
| 119 | chain.from_iterable( |
| 120 | [ |
| 121 | range(self._num_clips) |
| 122 | for _ in range(len(self._path_to_videos)) |
| 123 | ] |
| 124 | ) |
| 125 | ) |
| 126 | logger.info( |
| 127 | "Something-Something dataloader constructed " |
| 128 | " (size: {}) from {}".format( |
| 129 | len(self._path_to_videos), path_to_file |
| 130 | ) |
| 131 | ) |
| 132 | |
| 133 | def get_seq_frames(self, index, temporal_sample_index): |
| 134 | """ |