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

Function hflip

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

Source from the content-addressed store, hash-verified

57
58
59def hflip(image, target):
60 flipped_image = F.hflip(image)
61
62 w, h = image.size
63
64 target = target.copy()
65 if "boxes" in target:
66 boxes = target["boxes"]
67 boxes = boxes[:, [2, 1, 0, 3]] * torch.as_tensor([-1, 1, -1, 1]) + torch.as_tensor([w, 0, w, 0])
68 target["boxes"] = boxes
69
70 if "masks" in target:
71 target['masks'] = target['masks'].flip(-1)
72
73 return flipped_image, target
74
75
76def resize(image, target, size, max_size=None):

Callers 1

__call__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected