(img, image_size)
| 16 | |
| 17 | |
| 18 | def _load_img_v2_as_tensor(img, image_size): |
| 19 | img_pil = Image.fromarray(img.astype(np.uint8)) |
| 20 | img_np = np.array(img_pil.convert("RGB").resize((image_size, image_size))) |
| 21 | if img_np.dtype == np.uint8: # np.uint8 is expected for JPEG images |
| 22 | img_np = img_np / 255.0 |
| 23 | else: |
| 24 | raise RuntimeError(f"Unknown image dtype: {img_np.dtype}") |
| 25 | img = torch.from_numpy(img_np).permute(2, 0, 1) |
| 26 | video_width, video_height = img_pil.size # the original video size |
| 27 | return img, video_height, video_width |
| 28 | |
| 29 | |
| 30 | def load_video_frames( |
no test coverage detected