Skip to content

SSIM

Bases: Module

__init__

__init__(window_size: int = 11, return_cs: bool = False, **kwargs) -> None

Structural similarity index loss.

I.e. the dissimilarity: (1 - SSIM(x, y)) / 2

Parameters:

Name Type Description Default
window_size int, default=11

Size of the gaussian kernel.

11
return_cs bool, default=False

Return also the the contrast sensitivity coeff.

False

forward

forward(yhat: Tensor, target: Tensor, **kwargs) -> torch.Tensor

Compute the SSIM loss.

Parameters yhat (torch.Tensor): The prediction map. Shape (B, C, H, W). target (torch.Tensor): the ground truth annotations. Shape (B, H, W). target_weight (torch.Tensor, default=None): The edge weight map. Shape (B, H, W).

Returns:

Type Description
Tensor

torch.Tensor: Computed SSIM loss (scalar).