(clip, target_size, interpolation_mode)
| 66 | |
| 67 | |
| 68 | def resize_scale(clip, target_size, interpolation_mode): |
| 69 | if len(target_size) != 2: |
| 70 | raise ValueError( |
| 71 | f"target size should be tuple (height, width), instead got {target_size}" |
| 72 | ) |
| 73 | H, W = clip.size(-2), clip.size(-1) |
| 74 | scale_ = target_size[0] / min(H, W) |
| 75 | return torch.nn.functional.interpolate( |
| 76 | clip, scale_factor=scale_, mode=interpolation_mode, align_corners=False |
| 77 | ) |
| 78 | |
| 79 | |
| 80 | def resized_crop(clip, i, j, h, w, size, interpolation_mode="bilinear"): |