MCPcopy Create free account
hub / github.com/HobbitLong/PyContrast / __call__

Method __call__

pycontrast/datasets/util.py:145–163  ·  view source on GitHub ↗
(self, img)

Source from the content-addressed store, hash-verified

143 self.tensor_to_pil = transforms.ToPILImage()
144
145 def __call__(self, img):
146 img = self.pil_to_tensor(img).unsqueeze(0)
147
148 sigma = np.random.uniform(0.1, 2.0)
149 x = np.arange(-self.r, self.r + 1)
150 x = np.exp(-np.power(x, 2) / (2 * sigma * sigma))
151 x = x / x.sum()
152 x = torch.from_numpy(x).view(1, -1).repeat(3, 1)
153
154 self.blur_h.weight.data.copy_(x.view(3, 1, self.k, 1))
155 self.blur_v.weight.data.copy_(x.view(3, 1, 1, self.k))
156
157 with torch.no_grad():
158 img = self.blur(img)
159 img = img.squeeze()
160
161 img = self.tensor_to_pil(img)
162
163 return img
164
165
166class GaussianBlur2(object):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected