File size: 765 Bytes
1975737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
import torchvision.transforms as T
import torch.nn.functional as F

def blue_channel(images):
    error = torch.abs(images[:,2] - 0.9).mean() 
    return error

def elastic_transform(images):
    elastic_transformer = T.ElasticTransform(alpha=550.0,sigma=5.0)
    transformed_imgs = elastic_transformer(images)
    error = torch.abs(transformed_imgs - images).mean()
    return error

def symmetry(images):
    flipped_image = torch.flip(images, [3])
    error = F.mse_loss(images, flipped_image)
    print("Loss Calculated for the Symmetry : ", error)
    return error

def saturation(images):
    transformed_imgs = T.functional.adjust_saturation(images,saturation_factor = 10)
    error = torch.abs(transformed_imgs - images).mean()
    return error