Esempio n. 1
0
 def __init__(self,
              root,
              N,
              noise_level=1e-2,
              train=True,
              low_light=False,
              transform=None,
              target_transform=None,
              download=False):
     # transform = BlockGaussian(N)
     transform = th_transforms.Compose([
         torchvision.transforms.Resize(size=32),
         th_transforms.ToTensor(),
         ScaleZeroMean(),
         AddGaussianNoiseSetN2N(N, (0, 50.))
     ])
     th_trans = th_transforms.Compose(
         [torchvision.transforms.Resize(size=32),
          th_transforms.ToTensor()])
     self.__class__.__name__ = "mnist"
     super(DisentMNISTv1, self).__init__(root,
                                         train=train,
                                         transform=transform,
                                         target_transform=target_transform,
                                         download=download)
     self.th_trans = th_trans
Esempio n. 2
0
 def _get_msg_noise(self, params, N):
     """
     Noise Type: Multi-scale Gaussian  (MSG)
     - Each N images has it's own noise level
     """
     resize = torchvision.transforms.Resize(size=32)
     to_tensor = th_transforms.ToTensor()
     szm = ScaleZeroMean()
     gaussian_n2n = AddGaussianNoiseSetN2N(N, (0, 50.))
     comp = [resize, to_tensor, szm, gaussian_n2n]
     t = th_transforms.Compose(comp)
     return t
Esempio n. 3
0
 def __init__(self,
              root: str,
              N: int,
              noise_level: float,
              random_crop: bool,
              split: str = 'train',
              transform=None,
              target_transform=None):
     root = Path(root) / Path("imagenet/")
     if random_crop:
         transform = th_transforms.Compose([
             torchvision.transforms.Resize(size=256),
             torchvision.transforms.RandomCrop(size=256),
             th_transforms.ToTensor(),
             ScaleZeroMean(),
             AddGaussianNoiseSetN2N(N, (0, 50.))
         ])
     else:
         transform = th_transforms.Compose([
             torchvision.transforms.Resize(size=256),
             th_transforms.ToTensor(),
             ScaleZeroMean(),
             AddGaussianNoiseSetN2N(N, (0, 50.))
         ])
     th_trans = th_transforms.Compose([
         torchvision.transforms.Resize(size=256),
         th_transforms.ToTensor(),
         ScaleZeroMean(),
     ])
     super(DisentImageNetv1,
           self).__init__(root,
                          split,
                          None,
                          transform=transform,
                          target_transform=target_transform)
     self.th_trans = th_trans