(self, img)
| 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 | |
| 166 | class GaussianBlur2(object): |
nothing calls this directly
no outgoing calls
no test coverage detected