MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / pad

Function pad

SwissArmyTransformer/examples/yolos/datasets_/transforms.py:154–164  ·  view source on GitHub ↗
(image, target, padding)

Source from the content-addressed store, hash-verified

152
153
154def pad(image, target, padding):
155 # assumes that we only pad on the bottom right corners
156 padded_image = F.pad(image, (0, 0, padding[0], padding[1]))
157 if target is None:
158 return padded_image, None
159 target = target.copy()
160 # should we do something wrt the original size?
161 target["size"] = torch.tensor(padded_image.size[::-1])
162 if "masks" in target:
163 target['masks'] = torch.nn.functional.pad(target['masks'], (0, padding[0], 0, padding[1]))
164 return padded_image, target
165
166
167class RandomCrop(object):

Callers 2

process_fnFunction · 0.85
__call__Method · 0.85

Calls 1

padMethod · 0.80

Tested by

no test coverage detected