kaira.losses.image.SSIMLoss

Inheritance diagram of SSIMLoss

Inheritance diagram for SSIMLoss

class kaira.losses.image.SSIMLoss(kernel_size: int = 11, data_range: float = 1.0)[source]

Bases: BaseLoss

Structural Similarity Index Measure (SSIM) Loss Module.

This module calculates the SSIM loss between the input and the target. SSIM evaluates image similarity based on luminance, contrast, and structure, better matching human visual perception [Wang et al., 2004].

Methods

__init__

Initialize the SSIMLoss module.

forward

Forward pass through the SSIMLoss module.

__init__(kernel_size: int = 11, data_range: float = 1.0)[source]

Initialize the SSIMLoss module.

Parameters:
  • kernel_size (int) – Size of the Gaussian kernel used in SSIM calculation.

  • data_range (float) – Range of the input data (typically 1.0 or 255).

forward(x: Tensor, target: Tensor) Tensor[source]

Forward pass through the SSIMLoss module.

Parameters:
Returns:

The SSIM loss between the input and the target.

Return type:

torch.Tensor