img (PIL Image or Tensor): Image to be transformed. Returns: PIL Image or Tensor: AutoAugmented image.
(self, img: Tensor)
| 283 | return policy_id, probs, signs |
| 284 | |
| 285 | def forward(self, img: Tensor) -> Tensor: |
| 286 | """ |
| 287 | img (PIL Image or Tensor): Image to be transformed. |
| 288 | |
| 289 | Returns: |
| 290 | PIL Image or Tensor: AutoAugmented image. |
| 291 | """ |
| 292 | fill = self.fill |
| 293 | if isinstance(img, Tensor): |
| 294 | if isinstance(fill, (int, float)): |
| 295 | fill = [float(fill)] * F.get_image_num_channels(img) |
| 296 | elif fill is not None: |
| 297 | fill = [float(f) for f in fill] |
| 298 | |
| 299 | transform_id, probs, signs = self.get_params(len(self.policies)) |
| 300 | |
| 301 | for i, (op_name, p, magnitude_id) in enumerate(self.policies[transform_id]): |
| 302 | if probs[i] <= p: |
| 303 | op_meta = self._augmentation_space(10, F.get_image_size(img)) |
| 304 | magnitudes, signed = op_meta[op_name] |
| 305 | magnitude = float(magnitudes[magnitude_id].item()) if magnitude_id is not None else 0.0 |
| 306 | if signed and signs[i] == 0: |
| 307 | magnitude *= -1.0 |
| 308 | img = _apply_op(img, op_name, magnitude, interpolation=self.interpolation, fill=fill) |
| 309 | |
| 310 | return img |
| 311 | |
| 312 | def __repr__(self) -> str: |
| 313 | return self.__class__.__name__ + '(policy={}, fill={})'.format(self.policy, self.fill) |
nothing calls this directly
no test coverage detected