MCPcopy Create free account
hub / github.com/Sense-GVT/DeCLIP / CALSMultiResolutionTransform

Class CALSMultiResolutionTransform

prototype/data/transforms.py:56–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54 return torch.cat([base, q], dim=0)
55
56class CALSMultiResolutionTransform(object):
57 def __init__(self, base_transform, stronger_transfrom, num_res=5, resolutions=[96, 128, 160, 192, 224]):
58 '''
59 Note: RandomResizedCrop should be includeed in stronger_transfrom
60 '''
61 resolutions = resolutions
62 self.res = resolutions[:num_res]
63 self.resize_crop_ops = [transforms.RandomResizedCrop(res, scale=(0.2, 1.)) for res in self.res]
64 self.num_res = num_res
65
66 self.base_transform = base_transform
67 self.stronger_transfrom = stronger_transfrom
68
69 def __call__(self, x):
70 q = self.base_transform(x)
71 k = self.base_transform(x)
72 images = [q, k]
73
74 q_stronger_augs = []
75 for resize_crop_op in self.resize_crop_ops:
76 q_s = self.stronger_transfrom(resize_crop_op(x))
77 q_stronger_augs.append(q_s)
78
79 images.extend(q_stronger_augs)
80 return images
81
82class GaussianBlur(object):
83 """Gaussian blur augmentation in SimCLR https://arxiv.org/abs/2002.05709"""

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected