MCPcopy Create free account
hub / github.com/RylonW/DocNLC / augment

Function augment

data/util.py:166–181  ·  view source on GitHub ↗

horizontal flip OR rotate (0, 90, 180, 270 degrees)

(img_list, hflip=True, rot=True)

Source from the content-addressed store, hash-verified

164
165
166def augment(img_list, hflip=True, rot=True):
167 """horizontal flip OR rotate (0, 90, 180, 270 degrees)"""
168 hflip = hflip and random.random() < 0.5
169 vflip = rot and random.random() < 0.5
170 rot90 = rot and random.random() < 0.5
171
172 def _augment(img):
173 if hflip:
174 img = img[:, ::-1, :]
175 if vflip:
176 img = img[::-1, :, :]
177 if rot90:
178 img = img.transpose(1, 0, 2)
179 return img
180
181 return [_augment(img) for img in img_list]
182
183
184def augment_flow(img_list, flow_list, hflip=True, rot=True):

Callers

nothing calls this directly

Calls 1

_augmentFunction · 0.70

Tested by

no test coverage detected