Load the video frames from a directory of JPEG files (" .jpg" format). The frames are resized to image_size x image_size and are loaded to GPU if `offload_video_to_cpu` is `False` and to CPU if `offload_video_to_cpu` is `True`. You can load a frame asynchronously by se
(
imgs_tensor,
offload_video_to_cpu,
img_mean=(0.485, 0.456, 0.406),
img_std=(0.229, 0.224, 0.225),
async_loading_frames=False,
)
| 213 | return images, video_height, video_width |
| 214 | |
| 215 | def load_video_frames_from_data( |
| 216 | imgs_tensor, |
| 217 | offload_video_to_cpu, |
| 218 | img_mean=(0.485, 0.456, 0.406), |
| 219 | img_std=(0.229, 0.224, 0.225), |
| 220 | async_loading_frames=False, |
| 221 | ): |
| 222 | """ |
| 223 | Load the video frames from a directory of JPEG files ("<frame_index>.jpg" format). |
| 224 | |
| 225 | The frames are resized to image_size x image_size and are loaded to GPU if |
| 226 | `offload_video_to_cpu` is `False` and to CPU if `offload_video_to_cpu` is `True`. |
| 227 | |
| 228 | You can load a frame asynchronously by setting `async_loading_frames` to `True`. |
| 229 | """ |
| 230 | |
| 231 | num_frames = imgs_tensor.shape[0] |
| 232 | |
| 233 | img_mean = torch.tensor(img_mean, dtype=torch.float32)[:, None, None] |
| 234 | img_std = torch.tensor(img_std, dtype=torch.float32)[:, None, None] |
| 235 | |
| 236 | images = imgs_tensor / 255.0 |
| 237 | if not offload_video_to_cpu: |
| 238 | images = images.cuda() |
| 239 | img_mean = img_mean.cuda() |
| 240 | img_std = img_std.cuda() |
| 241 | # normalize by mean and std |
| 242 | images -= img_mean |
| 243 | images /= img_std |
| 244 | return images |
| 245 | |
| 246 | |
| 247 | def fill_holes_in_mask_scores(mask, max_area): |
no outgoing calls
no test coverage detected