(self, index)
| 136 | self.thread.start() |
| 137 | |
| 138 | def __getitem__(self, index): |
| 139 | if self.exception is not None: |
| 140 | raise RuntimeError("Failure in frame loading thread") from self.exception |
| 141 | |
| 142 | img = self.images[index] |
| 143 | if img is not None: |
| 144 | return img |
| 145 | |
| 146 | img, video_height, video_width = _load_img_as_tensor( |
| 147 | self.img_paths[index], self.image_size |
| 148 | ) |
| 149 | self.video_height = video_height |
| 150 | self.video_width = video_width |
| 151 | # normalize by mean and std |
| 152 | img -= self.img_mean |
| 153 | img /= self.img_std |
| 154 | if not self.offload_video_to_cpu: |
| 155 | img = img.cuda(non_blocking=True) |
| 156 | self.images[index] = img |
| 157 | return img |
| 158 | |
| 159 | def __len__(self): |
| 160 | return len(self.images) |
no test coverage detected