Esempio 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
Esempio 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
Esempio 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
Esempio 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
Esempio 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