MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / CutoutAbs

Function CutoutAbs

PATH/core/data/transforms/pedattr_transforms.py:198–216  ·  view source on GitHub ↗
(img, v)

Source from the content-addressed store, hash-verified

196
197
198def CutoutAbs(img, v): # [0, 60] => percentage: [0, 0.2]
199 # assert 0 <= v <= 20
200 if v < 0:
201 return img
202 w, h = img.size
203 x0 = np.random.uniform(w)
204 y0 = np.random.uniform(h)
205
206 x0 = int(max(0, x0 - v / 2.))
207 y0 = int(max(0, y0 - v / 2.))
208 x1 = min(w, x0 + v)
209 y1 = min(h, y0 + v)
210
211 xy = (x0, y0, x1, y1)
212 color = (125, 123, 114)
213 # color = (0, 0, 0)
214 img = img.copy()
215 PIL.ImageDraw.Draw(img).rectangle(xy, color)
216 return img
217
218
219def SamplePairing(imgs): # [0, 0.4]

Callers 1

CutoutFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected