anomalib.models.cflow¶
Real-Time Unsupervised Anomaly Detection via Conditional Normalizing Flows.
Submodules¶
Package Contents¶
Classes¶
PL Lightning Module for the CFLOW algorithm. |
|
PL Lightning Module for the CFLOW algorithm. |
- class anomalib.models.cflow.Cflow(input_size: Tuple[int, int], backbone: str, layers: List[str], pre_trained: bool = True, fiber_batch_size: int = 64, decoder: str = 'freia-cflow', condition_vector: int = 128, coupling_blocks: int = 8, clamp_alpha: float = 1.9, permute_soft: bool = False, lr: float = 0.0001)[source]¶
Bases:
anomalib.models.components.AnomalyModulePL Lightning Module for the CFLOW algorithm.
- configure_optimizers() torch.optim.Optimizer¶
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, _)¶
Training Step of CFLOW.
For each batch, decoder layers are trained with a dynamic fiber batch size. Training step is performed manually as multiple training steps are involved
per batch of input images
- Parameters
batch – Input batch
_ – Index of the batch.
- Returns
Loss value for the batch
- validation_step(batch, _)¶
Validation Step of CFLOW.
Similar to the training step, encoder features are extracted from the CNN for each batch, and anomaly map is computed.
- Parameters
batch – Input batch
_ – Index of the batch.
- Returns
Dictionary containing images, anomaly maps, true labels and masks. These are required in validation_epoch_end for feature concatenation.
- class anomalib.models.cflow.CflowLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig])[source]¶
Bases:
CflowPL Lightning Module for the CFLOW algorithm.
- Parameters
hparams (Union[DictConfig, ListConfig]) – Model params
- configure_callbacks()¶
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.