FUVAS#

FUVAS: Few-shot Unsupervised Video Anomaly Segmentation via Low-Rank Factorization of Spatio-Temporal Features.

The FUVAS model extracts deep features from video clips using a pre-trained 3D CNN/transformer backbone and fits a PCA-based reconstruction model to detect anomalies. The model computes feature reconstruction errors to identify anomalous frames and regions in videos.

Example

>>> from anomalib.models.video import Fuvas
>>> model = Fuvas(
...     backbone="x3d_s",
...     layer="blocks.4"
... )

The model can be used with video anomaly detection datasets supported in anomalib.

Notes

The model implementation is available in the lightning_model module.

See also

anomalib.models.video.fuvas.lightning_model.Fuvas:

Lightning implementation of the FUVAS model.

class anomalib.models.video.fuvas.Fuvas(backbone='x3d_s', layer='blocks.4', pre_trained=True, spatial_pool=True, pooling_kernel_size=1, pca_level=0.98, pre_processor=True, post_processor=True, evaluator=True, visualizer=True)#

Bases: MemoryBankMixin, AnomalibModule

FUVAS Lightning Module.

Parameters:
  • backbone (str) – Name of the backbone 3D CNN/transformer network. Defaults to "x3d_s".

  • layer (str) – Name of the layer to extract features from the backbone. Defaults to "blocks.4".

  • pre_trained (bool) – Whether to use a pre-trained backbone. Defaults to True.

  • spatial_pool (bool) – Whether to use spatial pooling on features. Defaults to True.

  • pooling_kernel_size (int) – Kernel size for pooling features. Defaults to 1.

  • pca_level (float) – Ratio of variance to preserve in PCA. Must be between 0 and 1. Defaults to 0.98.

  • pre_processor (PreProcessor | bool) – Pre-processor to use. If True, uses the default pre-processor. If False, no pre-processing is performed. Defaults to True.

  • post_processor (PostProcessor | bool) – Post-processor to use. If True, uses the default post-processor. If False, no post-processing is performed. Defaults to True.

  • evaluator (Evaluator | bool) – Evaluator to use. If True, uses the default evaluator. If False, no evaluation is performed. Defaults to True.

  • visualizer (Visualizer | bool) – Visualizer to use. If True, uses the default visualizer. If False, no visualization is performed. Defaults to True.

static configure_optimizers()#

Configure optimizers for training.

Returns:

FUVAS doesn’t require optimization.

Return type:

None

fit()#

Fit the PCA transformation to the embeddings.

The method aggregates embeddings collected during training and fits the PCA transformation used for anomaly scoring.

Return type:

None

property learning_type: LearningType#

Get the learning type of the model.

Returns:

The model uses one-class learning.

Return type:

LearningType

property trainer_arguments: dict[str, Any]#

Get FUVAS-specific trainer arguments.

Returns:

Dictionary of trainer arguments:
  • gradient_clip_val (int): Disable gradient clipping

  • max_epochs (int): Train for one epoch only

  • num_sanity_val_steps (int): Skip validation sanity checks

Return type:

dict[str, Any]

training_step(batch, *args, **kwargs)#

Extract features from the input batch during training.

Parameters:
  • batch (Batch) – Input batch containing video clips.

  • *args – Additional positional arguments (unused).

  • **kwargs – Additional keyword arguments (unused).

Returns:

Dummy loss tensor for compatibility.

Return type:

Tensor

validation_step(batch, *args, **kwargs)#

Compute predictions for the input batch during validation.

Parameters:
  • batch (Batch) – Input batch containing video clips.

  • *args – Additional positional arguments (unused).

  • **kwargs – Additional keyword arguments (unused).

Returns:

Dictionary containing anomaly scores and maps.

Return type:

Union[Tensor, Mapping[str, Any], None]