Visual Information Fidelity (VIF)

Module Interface

class torchmetrics.image.VisualInformationFidelity(sigma_n_sq=2.0, **kwargs)[source]

Compute Pixel Based Visual Information Fidelity (VIF).

As input to forward and update the metric accepts the following input

  • preds (Tensor): Predictions from model of shape (N,C,H,W) with H,W ≥ 41

  • target (Tensor): Ground truth values of shape (N,C,H,W) with H,W ≥ 41

As output of forward and compute the metric returns the following output

  • vif-p (Tensor): Tensor with vif-p score

Parameters:

Example

>>> import torch
>>> _ = torch.manual_seed(42)
>>> from torchmetrics.image import VisualInformationFidelity
>>> preds = torch.randn([32, 3, 41, 41])
>>> target = torch.randn([32, 3, 41, 41])
>>> vif = VisualInformationFidelity()
>>> vif(preds, target)
tensor(0.0032)

Functional Interface

torchmetrics.functional.image.visual_information_fidelity(preds, target, sigma_n_sq=2.0)[source]

Compute Pixel Based Visual Information Fidelity (VIF).

Parameters:
  • preds (Tensor) – predicted images of shape (N,C,H,W). (H, W) has to be at least (41, 41).

  • target (Tensor) – ground truth images of shape (N,C,H,W). (H, W) has to be at least (41, 41)

  • sigma_n_sq (float) – variance of the visual noise

Return type:

Tensor

Returns:

Tensor with vif-p score

Raises:

ValueError – If data_range is neither a tuple nor a float