horizontal flip OR rotate (0, 90, 180, 270 degrees)
(img_list, hflip=True, rot=True)
| 164 | |
| 165 | |
| 166 | def 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 | |
| 184 | def augment_flow(img_list, flow_list, hflip=True, rot=True): |
nothing calls this directly
no test coverage detected