MCPcopy Create free account
hub / github.com/TorchSSL/TorchSSL / CutoutAbs

Function CutoutAbs

datasets/augmentation/randaugment.py:123–141  ·  view source on GitHub ↗
(img, v)

Source from the content-addressed store, hash-verified

121
122
123def CutoutAbs(img, v): # [0, 60] => percentage: [0, 0.2]
124 # assert 0 <= v <= 20
125 if v < 0:
126 return img
127 w, h = img.size
128 x0 = np.random.uniform(w)
129 y0 = np.random.uniform(h)
130
131 x0 = int(max(0, x0 - v / 2.))
132 y0 = int(max(0, y0 - v / 2.))
133 x1 = min(w, x0 + v)
134 y1 = min(h, y0 + v)
135
136 xy = (x0, y0, x1, y1)
137 color = (125, 123, 114)
138 # color = (0, 0, 0)
139 img = img.copy()
140 PIL.ImageDraw.Draw(img).rectangle(xy, color)
141 return img
142
143
144def augment_list():

Callers 1

CutoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected