anomalib.models.ganomaly.lightning_model¶
GANomaly: Semi-Supervised Anomaly Detection via Adversarial Training.
https://arxiv.org/abs/1805.06725
Module Contents¶
Classes¶
PL Lightning Module for the GANomaly Algorithm. |
|
PL Lightning Module for the GANomaly Algorithm. |
Attributes¶
- class anomalib.models.ganomaly.lightning_model.Ganomaly(batch_size: int, input_size: Tuple[int, int], n_features: int, latent_vec_size: int, extra_layers: int = 0, add_final_conv_layer: bool = True, wadv: int = 1, wcon: int = 50, wenc: int = 1, lr: float = 0.0002, beta1: float = 0.5, beta2: float = 0.999)[source]¶
Bases:
anomalib.models.components.AnomalyModulePL Lightning Module for the GANomaly Algorithm.
- Parameters
batch_size (int) – Batch size.
input_size (Tuple[int,int]) – Input dimension.
n_features (int) – Number of features layers in the CNNs.
latent_vec_size (int) – Size of autoencoder latent vector.
extra_layers (int, optional) – Number of extra layers for encoder/decoder. Defaults to 0.
add_final_conv_layer (bool, optional) – Add convolution layer at the end. Defaults to True.
wadv (int, optional) – Weight for adversarial loss. Defaults to 1.
wcon (int, optional) – Image regeneration weight. Defaults to 50.
wenc (int, optional) – Latent vector encoder weight. Defaults to 1.
- configure_optimizers() List[torch.optim.Optimizer][source]¶
Configures optimizers for each decoder.
Note
This method is used for the existing CLI. When PL CLI is introduced, configure optimizers method will be
deprecated, and optimizers will be configured from either config.yaml file or from CLI.
- Returns
Adam optimizer for each decoder
- Return type
Optimizer
- training_step(batch, _, optimizer_idx)[source]¶
Training step.
- Parameters
batch (Dict) – Input batch containing images.
optimizer_idx (int) – Optimizer which is being called for current training step.
- Returns
Loss
- Return type
Dict[str, Tensor]