MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / resize

Method resize

tools/postprocess/torchvision_fix.py:35–52  ·  view source on GitHub ↗
(img, size, interpolation=2, antialias=None)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected