(tensor, num_frames)
| 88 | |
| 89 | |
| 90 | def pad_last_frame(tensor, num_frames): |
| 91 | # T, H, W, C |
| 92 | if tensor.shape[0] < num_frames: |
| 93 | last_frame = tensor[-int(num_frames - tensor.shape[1]) :] |
| 94 | padded_tensor = torch.cat([tensor, last_frame], dim=0) |
| 95 | return padded_tensor |
| 96 | else: |
| 97 | return tensor[:num_frames] |
| 98 | |
| 99 | def load_image_to_tensor(image_path): |
| 100 | if not os.path.exists(image_path): |