Args: horiz (bool): use horizontal flip. vert (bool): use vertical flip. prob (float): probability of flip.
(self, horiz=False, vert=False, prob=0.5)
| 16 | Random flip the image either horizontally or vertically. |
| 17 | """ |
| 18 | def __init__(self, horiz=False, vert=False, prob=0.5): |
| 19 | """ |
| 20 | Args: |
| 21 | horiz (bool): use horizontal flip. |
| 22 | vert (bool): use vertical flip. |
| 23 | prob (float): probability of flip. |
| 24 | """ |
| 25 | super(Flip, self).__init__() |
| 26 | if horiz and vert: |
| 27 | raise ValueError("Cannot do both horiz and vert. Please use two Flip instead.") |
| 28 | if not horiz and not vert: |
| 29 | raise ValueError("At least one of horiz or vert has to be True!") |
| 30 | self._init(locals()) |
| 31 | |
| 32 | def get_transform(self, img): |
| 33 | h, w = img.shape[:2] |