:py:mod:`anomalib.models.cflow` =============================== .. py:module:: anomalib.models.cflow .. autoapi-nested-parse:: Real-Time Unsupervised Anomaly Detection via Conditional Normalizing Flows. Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 anomaly_map/index.rst lightning_model/index.rst torch_model/index.rst utils/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: anomalib.models.cflow.Cflow anomalib.models.cflow.CflowLightning .. py:class:: 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) Bases: :py:obj:`anomalib.models.components.AnomalyModule` PL Lightning Module for the CFLOW algorithm. .. py:method:: 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 :rtype: Optimizer .. py:method:: 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 :param batch: Input batch :param _: Index of the batch. :returns: Loss value for the batch .. py:method:: 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. :param batch: Input batch :param _: Index of the batch. :returns: Dictionary containing images, anomaly maps, true labels and masks. These are required in `validation_epoch_end` for feature concatenation. .. py:class:: CflowLightning(hparams: Union[omegaconf.DictConfig, omegaconf.ListConfig]) Bases: :py:obj:`Cflow` PL Lightning Module for the CFLOW algorithm. :param hparams: Model params :type hparams: Union[DictConfig, ListConfig] .. py:method:: 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.