| 344 | |
| 345 | |
| 346 | class CenterCropVideo: |
| 347 | def __init__( |
| 348 | self, |
| 349 | size, |
| 350 | interpolation_mode="bilinear", |
| 351 | ): |
| 352 | if isinstance(size, tuple): |
| 353 | if len(size) != 2: |
| 354 | raise ValueError( |
| 355 | f"size should be tuple (height, width), instead got {size}" |
| 356 | ) |
| 357 | self.size = size |
| 358 | else: |
| 359 | self.size = (size, size) |
| 360 | |
| 361 | self.interpolation_mode = interpolation_mode |
| 362 | |
| 363 | def __call__(self, clip): |
| 364 | """ |
| 365 | Args: |
| 366 | clip (torch.tensor): Video clip to be cropped. Size is (T, C, H, W) |
| 367 | Returns: |
| 368 | torch.tensor: center cropped video clip. |
| 369 | size is (T, C, crop_size, crop_size) |
| 370 | """ |
| 371 | clip_center_crop = center_crop(clip, self.size) |
| 372 | return clip_center_crop |
| 373 | |
| 374 | def __repr__(self) -> str: |
| 375 | return f"{self.__class__.__name__}(size={self.size}, interpolation_mode={self.interpolation_mode}" |
| 376 | |
| 377 | |
| 378 | class NormalizeVideo: |
nothing calls this directly
no outgoing calls
no test coverage detected