anomalib.models.draem.utils

Helpers for the DRAEM model implementation.

Submodules

Package Contents

Classes

Augmenter

Class that generates noisy augmentations of input images.

class anomalib.models.draem.utils.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

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]

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]

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.