(img, size, interpolation=2, antialias=None)
| 33 | |
| 34 | @staticmethod |
| 35 | def resize(img, size, interpolation=2, antialias=None): |
| 36 | try: |
| 37 | from torchvision.transforms.v2.functional import resize as v2_resize |
| 38 | |
| 39 | return v2_resize(img, size, interpolation=interpolation, antialias=antialias) |
| 40 | except ImportError: |
| 41 | if hasattr(F, "resize"): |
| 42 | return F.resize(img, size, interpolation=interpolation) |
| 43 | import torch.nn.functional as torch_F |
| 44 | |
| 45 | if isinstance(size, int): |
| 46 | size = (size, size) |
| 47 | return torch_F.interpolate( |
| 48 | img.unsqueeze(0) if len(img.shape) == 3 else img, |
| 49 | size=size, |
| 50 | mode="bilinear", |
| 51 | align_corners=False, |
| 52 | ) |
| 53 | |
| 54 | def __getattr__(self, name): |
| 55 | if hasattr(F, name): |
nothing calls this directly
no outgoing calls
no test coverage detected