MCPcopy Create free account
hub / github.com/CompVis/diff2flow / resize

Function resize

diff2flow/dataset/depth_preprocessing.py:62–73  ·  view source on GitHub ↗
(sample, size)

Source from the content-addressed store, hash-verified

60
61
62def resize(sample, size):
63 if len(sample.shape) == 4:
64 return torch.nn.functional.interpolate(sample, size=size)
65 elif len(sample.shape) == 3:
66 if sample.shape[0] > 3:
67 # H x W x C -> C x H x W
68 sample = sample.permute(2, 0, 1)
69 return torch.nn.functional.interpolate(sample[None], size=size).squeeze(0)
70 elif len(sample.shape) == 2:
71 return torch.nn.functional.interpolate(sample[None, None], size=size).squeeze(0).squeeze(0)
72 else:
73 raise ValueError("Invalid shape: {}".format(sample.shape))
74
75
76def preprocess_depth(depth, dataset_name, out_channels=3, keep_raw_depth=False):

Callers 1

preprocess_sampleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected