Пример #1
0
class ACDCStrongTransforms:
    pretrain = SequentialWrapperTwice(
        comm_transform=pil_augment.Compose([
            pil_augment.RandomRotation(30),
            pil_augment.RandomVerticalFlip(),
            pil_augment.RandomHorizontalFlip(),
            pil_augment.RandomCrop(224),
        ]),
        img_transform=pil_augment.Compose([
            transforms.ColorJitter(brightness=[0.5, 1.5],
                                   contrast=[0.5, 1.5],
                                   saturation=[0.5, 1.5]),
            transforms.ToTensor()
        ]),
        target_transform=pil_augment.Compose([pil_augment.ToLabel()]),
        total_freedom=True)
    label = SequentialWrapperTwice(
        comm_transform=pil_augment.Compose([
            pil_augment.RandomCrop(224),
            pil_augment.RandomRotation(30),
        ]),
        img_transform=pil_augment.Compose([transforms.ToTensor()]),
        target_transform=pil_augment.Compose([pil_augment.ToLabel()]),
    )
    val = SequentialWrapper(comm_transform=pil_augment.CenterCrop(224))
 def __init__(self, comm_transform: Callable[[Image.Image], Image.Image] = None,
              img_transform: Callable[[Image.Image], Tensor] = pil_augment.ToTensor(),
              target_transform: Callable[[Image.Image], Tensor] = pil_augment.ToLabel(),
              total_freedom=True) -> None:
     """
     :param total_freedom: if True, the two-time generated images are using different seeds for all aspect,
                           otherwise, the images are used different random seed only for img_seed
     """
     super().__init__(comm_transform, img_transform, target_transform)
     self._total_freedom = total_freedom
Пример #3
0
class ACDCTransforms:
    pretrain = SequentialWrapperTwice(
        comm_transform=pil_augment.Compose([
            pil_augment.RandomCrop(224),
            pil_augment.RandomRotation(30),  # interpolation to be nearest
        ]),
        img_transform=pil_augment.Compose([
            transforms.ColorJitter(brightness=[0.8, 1.3],
                                   contrast=[0.8, 1.3],
                                   saturation=[0.8, 1.3]),
            transforms.ToTensor()
        ]),
        target_transform=pil_augment.Compose([pil_augment.ToLabel()]),
        total_freedom=True)
    label = SequentialWrapperTwice(
        comm_transform=pil_augment.Compose([
            pil_augment.RandomCrop(224),
            pil_augment.RandomRotation(30),  # interpolation to be nearest
        ]),
        img_transform=pil_augment.Compose([transforms.ToTensor()]),
        target_transform=pil_augment.Compose([pil_augment.ToLabel()]),
    )
    val = SequentialWrapper(comm_transform=pil_augment.CenterCrop(224))
 def __init__(
     self,
     comm_transform: Callable[[Image.Image], Image.Image] = None,
     img_transform: Callable[[Image.Image], Tensor] = pil_augment.ToTensor(),
     target_transform: Callable[[Image.Image], Tensor] = pil_augment.ToLabel()
 ) -> None:
     """
     :param comm_transform: common geo-transformation
     :param img_transform: transformation only applied for images
     :param target_transform: transformation only applied for targets
     """
     self._comm_transform = comm_transform
     self._img_transform = img_transform
     self._target_transform = target_transform