anomalib.models.draem.lightning_model

DRÆM – A discriminatively trained reconstruction embedding for surface anomaly detection.

Paper https://arxiv.org/abs/2108.07610

Module Contents

Classes

Draem

DRÆM: A discriminatively trained reconstruction embedding for surface anomaly detection.

DraemLightning

DRÆM: A discriminatively trained reconstruction embedding for surface anomaly detection.

class anomalib.models.draem.lightning_model.Draem(anomaly_source_path: Optional[str] = None)[source]

Bases: anomalib.models.components.AnomalyModule

DRÆM: A discriminatively trained reconstruction embedding for surface anomaly detection.

Parameters

anomaly_source_path (Optional[str]) – Path to folder that contains the anomaly source images. Random noise will be used if left empty.

training_step(self, batch, _)[source]

Training Step of DRAEM.

Feeds the original image and the simulated anomaly image through the network and computes the training loss.

Parameters

batch (Dict[str, Any]) – Batch containing image filename, image, label and mask

Returns

Loss dictionary

validation_step(self, batch, _)[source]

Validation step of DRAEM. The Softmax predictions of the anomalous class are used as anomaly map.

Parameters

batch – Batch of input images

Returns

Dictionary to which predicted anomaly maps have been added.

class anomalib.models.draem.lightning_model.DraemLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig])[source]

Bases: Draem

DRÆM: A discriminatively trained reconstruction embedding for surface anomaly detection.

Parameters

hparams (Union[DictConfig, ListConfig]) – Model parameters

configure_callbacks(self)[source]

Configure model-specific callbacks.

Note

This method is used for the existing CLI. When PL CLI is introduced, configure callback method will be

deprecated, and callbacks will be configured from either config.yaml file or from CLI.

configure_optimizers(self)[source]

Configure the Adam optimizer.