(img_list, hflip=True, rot=True)
| 467 | |
| 468 | |
| 469 | def augment_imgs(img_list, hflip=True, rot=True): |
| 470 | # horizontal flip OR rotate |
| 471 | hflip = hflip and random.random() < 0.5 |
| 472 | vflip = rot and random.random() < 0.5 |
| 473 | rot90 = rot and random.random() < 0.5 |
| 474 | |
| 475 | def _augment(img): |
| 476 | if hflip: |
| 477 | img = img[:, ::-1, :] |
| 478 | if vflip: |
| 479 | img = img[::-1, :, :] |
| 480 | if rot90: |
| 481 | img = img.transpose(1, 0, 2) |
| 482 | return img |
| 483 | |
| 484 | return [_augment(img) for img in img_list] |
| 485 | |
| 486 | |
| 487 | ''' |
nothing calls this directly
no test coverage detected