r"""Horizontally flip the given image randomly with a given probability. Input format must be nhwc. Args: prob(float, optional): probability of the image being flipped. Default value is 0.5.
| 756 | |
| 757 | |
| 758 | class RandomHorizontalFlip(Module): |
| 759 | r"""Horizontally flip the given image randomly with a given probability. |
| 760 | Input format must be nhwc. |
| 761 | |
| 762 | Args: |
| 763 | prob(float, optional): probability of the image being flipped. Default value is 0.5. |
| 764 | """ |
| 765 | |
| 766 | def __init__(self, prob=0.5): |
| 767 | super().__init__() |
| 768 | self.prob = prob |
| 769 | |
| 770 | def forward(self, inp): |
| 771 | if np.random.rand(1) < self.prob: |
| 772 | return flip(inp, horizontal=True) |
| 773 | return inp |
| 774 | |
| 775 | |
| 776 | class RandomVerticalFlip(Module): |
no outgoing calls