(self, img, _)
| 150 | self._init(locals()) |
| 151 | |
| 152 | def _augment(self, img, _): |
| 153 | img = img.astype('float32') |
| 154 | if self.all_channel: |
| 155 | mean = np.mean(img) |
| 156 | std = np.std(img) |
| 157 | else: |
| 158 | mean = np.mean(img, axis=(0, 1), keepdims=True) |
| 159 | std = np.std(img, axis=(0, 1), keepdims=True) |
| 160 | std = np.maximum(std, 1.0 / np.sqrt(np.prod(img.shape))) |
| 161 | img = (img - mean) / std |
| 162 | return img |
| 163 | |
| 164 | |
| 165 | class GaussianBlur(PhotometricAugmentor): |