def __init__(self, patch_size=8, overlap=4):
        """
        Args:
            patch_size: size of patches when cutting up the image into overlapping patches
            overlap: how much to overlap patches
        """
        if not _TORCHVISION_AVAILABLE:
            raise ModuleNotFoundError(  # pragma: no-cover
                'You want to use `transforms` from `torchvision` which is not installed yet.'
            )

        self.patch_size = patch_size
        self.overlap = overlap
        self.flip_lr = transforms.RandomHorizontalFlip(p=0.5)

        normalize = transforms.Normalize(
            mean=[x / 255.0 for x in [125.3, 123.0, 113.9]],
            std=[x / 255.0 for x in [63.0, 62.1, 66.7]])
        col_jitter = transforms.RandomApply(
            [transforms.ColorJitter(0.4, 0.4, 0.4, 0.2)], p=0.8)
        img_jitter = transforms.RandomApply([RandomTranslateWithReflect(4)],
                                            p=0.8)
        rnd_gray = transforms.RandomGrayscale(p=0.25)

        self.transforms = transforms.Compose([
            img_jitter,
            col_jitter,
            rnd_gray,
            transforms.ToTensor(),
            normalize,
            Patchify(patch_size=patch_size, overlap_size=overlap),
        ])
 def __init__(self, patch_size=8):
     # flipping image along vertical axis
     self.flip_lr = transforms.RandomHorizontalFlip(p=0.5)
     # image augmentation functions
     normalize = transforms.Normalize(
         mean=[x / 255.0 for x in [125.3, 123.0, 113.9]],
         std=[x / 255.0 for x in [63.0, 62.1, 66.7]])
     col_jitter = transforms.RandomApply(
         [transforms.ColorJitter(0.4, 0.4, 0.4, 0.2)], p=0.8)
     img_jitter = transforms.RandomApply([RandomTranslateWithReflect(4)],
                                         p=0.8)
     rnd_gray = transforms.RandomGrayscale(p=0.25)
     # main transform for self-supervised training
     self.train_transform = transforms.Compose([
         img_jitter,
         col_jitter,
         rnd_gray,
         transforms.ToTensor(),
         normalize,
         Patchify(patch_size=patch_size, overlap_size=patch_size // 2),
     ])
     # transform for testing
     self.test_transform = transforms.Compose([
         transforms.ToTensor(),
         normalize,
         Patchify(patch_size=patch_size, overlap_size=patch_size // 2),
     ])
    def __init__(self, patch_size=8, overlap=4):
        """
        Transforms used for CPC:

        Args:

            patch_size: size of patches when cutting up the image into overlapping patches
            overlap: how much to overlap patches

        Transforms::

            random_flip
            img_jitter
            col_jitter
            rnd_gray
            transforms.ToTensor()
            normalize
            Patchify(patch_size=patch_size, overlap_size=patch_size // 2)

        Example::

            # in a regular dataset
            CIFAR10(..., transforms=CPCTrainTransformsCIFAR10())

            # in a DataModule
            module = CIFAR10DataModule(PATH)
            train_loader = module.train_dataloader(batch_size=32, transforms=CPCTrainTransformsCIFAR10())

        """
        if not _TORCHVISION_AVAILABLE:
            raise ImportError(
                'You want to use `transforms` from `torchvision` which is not installed yet.'
            )

        self.patch_size = patch_size
        self.overlap = overlap
        self.flip_lr = transforms.RandomHorizontalFlip(p=0.5)

        normalize = transforms.Normalize(
            mean=[x / 255.0 for x in [125.3, 123.0, 113.9]],
            std=[x / 255.0 for x in [63.0, 62.1, 66.7]])
        col_jitter = transforms.RandomApply(
            [transforms.ColorJitter(0.4, 0.4, 0.4, 0.2)], p=0.8)
        img_jitter = transforms.RandomApply([RandomTranslateWithReflect(4)],
                                            p=0.8)
        rnd_gray = transforms.RandomGrayscale(p=0.25)

        self.transforms = transforms.Compose([
            img_jitter,
            col_jitter,
            rnd_gray,
            transforms.ToTensor(),
            normalize,
            Patchify(patch_size=patch_size, overlap_size=overlap),
        ])
    def __init__(self):
        """
        Transforms applied to AMDIM

        Transforms::

            img_jitter,
            col_jitter,
            rnd_gray,
            transforms.ToTensor(),
            normalize

        Example::

            x = torch.rand(5, 3, 32, 32)

            transform = AMDIMTrainTransformsCIFAR10()
            (view1, view2) = transform(x)

        """
        if not _TORCHVISION_AVAILABLE:
            raise ImportError(
                'You want to use `transforms` from `torchvision` which is not installed yet.'
            )

        # flipping image along vertical axis
        self.flip_lr = transforms.RandomHorizontalFlip(p=0.5)

        # image augmentation functions
        normalize = transforms.Normalize(
            mean=[x / 255.0 for x in [125.3, 123.0, 113.9]],
            std=[x / 255.0 for x in [63.0, 62.1, 66.7]])
        col_jitter = transforms.RandomApply(
            [transforms.ColorJitter(0.4, 0.4, 0.4, 0.2)], p=0.8)
        img_jitter = transforms.RandomApply([RandomTranslateWithReflect(4)],
                                            p=0.8)
        rnd_gray = transforms.RandomGrayscale(p=0.25)

        self.transforms = transforms.Compose([
            img_jitter, col_jitter, rnd_gray,
            transforms.ToTensor(), normalize
        ])
    def __init__(self):
        if not _TORCHVISION_AVAILABLE:
            raise ModuleNotFoundError(  # pragma: no-cover
                'You want to use `transforms` from `torchvision` which is not installed yet.'
            )

        # flipping image along vertical axis
        self.flip_lr = transforms.RandomHorizontalFlip(p=0.5)

        # image augmentation functions
        normalize = transforms.Normalize(
            mean=[x / 255.0 for x in [125.3, 123.0, 113.9]],
            std=[x / 255.0 for x in [63.0, 62.1, 66.7]])
        col_jitter = transforms.RandomApply(
            [transforms.ColorJitter(0.4, 0.4, 0.4, 0.2)], p=0.8)
        img_jitter = transforms.RandomApply([RandomTranslateWithReflect(4)],
                                            p=0.8)
        rnd_gray = transforms.RandomGrayscale(p=0.25)

        self.transforms = transforms.Compose([
            img_jitter, col_jitter, rnd_gray,
            transforms.ToTensor(), normalize
        ])