(video_path, fps)
| 174 | return video_tensor |
| 175 | |
| 176 | def process_tensor(video_path, fps): |
| 177 | # import decord |
| 178 | import torchvision.transforms as T |
| 179 | video_tensor = load_video_with_opencv(video_path) |
| 180 | # Resize to ensure minimum side is 336 |
| 181 | h, w = video_tensor.shape[2:] |
| 182 | scale = 336 / min(h, w) |
| 183 | if scale < 1: |
| 184 | new_h, new_w = int(h * scale), int(w * scale) |
| 185 | video_tensor = T.Resize((new_h, new_w))(video_tensor) |
| 186 | |
| 187 | video_tensor = video_tensor[::fps].float()[:MAX_FRAMES_OFFLINE] |
| 188 | |
| 189 | # Move to GPU |
| 190 | video_tensor = video_tensor.cuda() |
| 191 | print(f"Video tensor shape: {video_tensor.shape}, device: {video_tensor.device}") |
| 192 | |
| 193 | # run vggt |
| 194 | # process the image tensor |
| 195 | video_tensor = preprocess_image(video_tensor)[None] |
| 196 | return video_tensor |
| 197 | |
| 198 | def process_and_save_rgb(video_path, user_temp_dir, fps): |
| 199 | from torchvision.utils import save_image |
no test coverage detected