MCPcopy Create free account
hub / github.com/HYUNJS/SGT / get_transform

Method get_transform

projects/Datasets/Transforms/augmentation.py:46–56  ·  view source on GitHub ↗
(self, img)

Source from the content-addressed store, hash-verified

44 self.pad_color = pad_color
45
46 def get_transform(self, img):
47 shape = img.shape[:2] # shape = [height, width]
48 ratio = min(float(self.height) / shape[0], float(self.width) / shape[1])
49 new_shape = (round(shape[1] * ratio), round(shape[0] * ratio)) # new_shape = [width, height]
50 dw = (self.width - new_shape[0]) / 2.0 # width padding
51 dh = (self.height - new_shape[1]) / 2.0 # height padding
52 top, bottom = round(dh - 0.1), round(dh + 0.1)
53 left, right = round(dw - 0.1), round(dw + 0.1)
54 dst_constant = (top, bottom, left, right)
55 padding = (dw, dh)
56 return LetterBoxTransform(new_shape, dst_constant, ratio, padding, color=self.pad_color)
57
58
59class CenterAffine(Augmentation):

Callers

nothing calls this directly

Calls 1

LetterBoxTransformClass · 0.90

Tested by

no test coverage detected