anomalib.models.draem.utils.augmenter¶
Augmenter module to generates out-of-distribution samples for the DRAEM implementation.
Module Contents¶
Classes¶
Class that generates noisy augmentations of input images. |
Functions¶
|
Returns the smallest power of 2 greater than or equal to the input value. |
- anomalib.models.draem.utils.augmenter.nextpow2(value)[source]¶
Returns the smallest power of 2 greater than or equal to the input value.
- class anomalib.models.draem.utils.augmenter.Augmenter(anomaly_source_path: Optional[str] = None)[source]¶
Class that generates noisy augmentations of input images.
- Parameters
anomaly_source_path (Optional[str]) – Path to a folder of images that will be used as source of the anomalous
specified (noise. If not) –
instead. (random noise will be used) –
- rand_augmenter() imgaug.augmenters.Sequential[source]¶
Selects 3 random transforms that will be applied to the anomaly source images.
- Returns
A selection of 3 transforms.
- generate_perturbation(height: int, width: int, anomaly_source_path: Optional[str]) Tuple[numpy.ndarray, numpy.ndarray][source]¶
Generate an image containing a random anomalous perturbation using a source image.
- Parameters
height (int) – height of the generated image.
width – (int): width of the generated image.
anomaly_source_path (Optional[str]) – Path to an image file. If not provided, random noise will be used
instead. –
- Returns
Image containing a random anomalous perturbation, and the corresponding ground truth anomaly mask.
- augment_batch(batch: torch.Tensor) Tuple[torch.Tensor, torch.Tensor][source]¶
Generate anomalous augmentations for a batch of input images.
- Parameters
batch (Tensor) – Batch of input images
- Returns
Augmented image to which anomalous perturbations have been added.
Ground truth masks corresponding to the anomalous perturbations.