def __init__(self, sigma, canopy, rotation_angle=180.0):
     super(RotationNoiseTransformer, self).__init__()
     self.sigma = sigma
     self.noise_adder = transforms.Noise(self.sigma)
     self.rotation_adder = transforms.Rotation(canopy, rotation_angle)
     self.round = 2
     self.masking = True
 def __init__(self, sigma, b, canopy, sl, sr):
     super(ResizeBrightnessNoiseTransformer, self).__init__()
     self.resize_adder = transforms.Resize(canopy, sl, sr)
     self.noise_adder = transforms.Noise(sigma)
     self.brightness_adder = transforms.BrightnessShift(b)
     self.sigma = sigma
     self.b = b
 def __init__(self, sigma, b, canopy, rotation_angle=180.0):
     super(RotationBrightnessNoiseTransformer, self).__init__()
     self.sigma = sigma
     self.b = b
     self.noise_adder = transforms.Noise(self.sigma)
     self.brightness_adder = transforms.BrightnessShift(self.b)
     self.rotation_adder = transforms.Rotation(canopy, rotation_angle)
     self.round = 2
     self.masking = True
 def __init__(self, sigma, b, k, canopy, rotation_angle=180.0):
     super(RotationBrightnessContrastNoiseTransformer, self).__init__()
     self.sigma = sigma
     self.sigma_b = b
     self.sigma_k = k
     self.noise_adder = transforms.Noise(self.sigma)
     self.scaler = transforms.BrightnessScale(self.sigma_k)
     self.brightness_adder = transforms.BrightnessShift(self.sigma_b)
     self.rotation_adder = transforms.Rotation(canopy, rotation_angle)
     self.input_dim = canopy.numel()
     self.round = 2
     self.masking = True
     self.k_l = self.k_r = 0
    def __init__(self, sigma, sigma_k, sigma_b, lamb, sigma_trans, sl, sr,
                 rotation_angle, canopy):
        super(UniversalTransformer, self).__init__()
        self.sigma = sigma

        self.sigma_k = sigma_k
        self.sigma_b = sigma_b
        self.scaler = transforms.BrightnessScale(sigma_k)
        self.brighter = transforms.BrightnessShift(sigma_b)
        self.gaussian_adder = transforms.ExpGaussian(lamb)
        self.translation_adder = transforms.Translational(canopy, sigma_trans)
        self.resize_adder = transforms.Resize(canopy, sl, sr)
        self.rotation_adder = transforms.Rotation(canopy, rotation_angle)
        self.noise_adder = transforms.Noise(self.sigma)
        self.round = 1
        self.masking = True
dir = 'visualize'

datasets = ['cifar10', 'mnist']
nums = [0, 20, 40, 60, 80, 100]

if __name__ == '__main__':

    for dataset in datasets:

        ds = get_dataset(dataset, 'test')

        canopy = ds[0][0]

        # init transformers
        noiseT = transforms.Noise(sigma=0.5)
        rotationT = transforms.Rotation(canopy, rotation_angle=180.0)
        translationT = transforms.Translational(canopy, sigma=5.0)
        blackTranslationT = transforms.BlackTranslational(canopy, sigma=5.0)
        brightnessShiftT = transforms.BrightnessShift(sigma=0.1)
        brightnessScaleT = transforms.BrightnessScale(sigma=0.1)
        sizeScaleT = transforms.Resize(canopy, sl=0.5, sr=5.0)
        gaussianT = transforms.Gaussian(sigma=5.0)

        for num in nums:
            print(dataset, num)
            transforms.visualize(ds[num][0], f'visualize/{dataset}/{num}.png')
            # rotation
            angles = [-10, 30, 70]
            for angle in angles:
                transforms.visualize(
 def __init__(self, canopy, sl, sr, sigma):
     super(ResizeNoiseTransformer, self).__init__()
     self.resize_adder = transforms.Resize(canopy, sl, sr)
     self.noise_adder = transforms.Noise(sigma)
 def __init__(self, sigma):
     super(NoiseTransformer, self).__init__()
     self.sigma = sigma
     self.noise_adder = transforms.Noise(self.sigma)