Exemplo n.º 1
0
    def __call__(self, image, target):
        t = random.random()
        if t < self.flip_prob:
            image = F.hflip(image)
        target = target if (type(target) == str
                            or t >= self.flip_prob) else F.hflip(target)

        return image, target
Exemplo n.º 2
0
    def __call__(self, img, target):
        """
        Args:
            img (PIL Image): Image to be flipped.

        Returns:
            PIL Image: Randomly flipped image.
        """
        if random.random() < 0.5:
            return F.hflip(img),F.hflip(target)
        return img, target
Exemplo n.º 3
0
 def __call__(self, img):
     """
     Args:
         img (PIL Image): Image to be flipped.
     Returns:
         PIL Image: Randomly flipped image.
     """
     if random.random() < self.p:
         return F.hflip(img)
     return img
Exemplo n.º 4
0
    def __call__(self, sample):
        """
        Args:
            img (PIL Image): Image to be flipped.

        Returns:
            PIL Image: Randomly flipped image.
        """
        if random.random() < 0.5:
            return F.hflip(sample)
        return sample
Exemplo n.º 5
0
 def __call__(self, img):
     """random
     Args:
         img (numpy ndarray): Image to be flipped.
     Returns:
         numpy ndarray: Randomly flipped image.
     """
     # if random.random() < self.p:
     #     print('flip')
     #     return F.hflip(img)
     if random.random() < self.p:
         return F.hflip(img)
     return img