kaira.metrics.image.StructuralSimilarityIndexMeasure

Inheritance diagram for StructuralSimilarityIndexMeasure
- class kaira.metrics.image.StructuralSimilarityIndexMeasure(data_range: float = 1.0, kernel_size: int = 11, sigma: float = 1.5, reduction: str | None = None, *args: Any, **kwargs: Any)[source]
Bases:
BaseMetricStructural Similarity Index Measure (SSIM) Module.
SSIM measures the perceptual difference between two similar images. Values range from 0 to 1, where 1 means perfect similarity. The metric considers luminance, contrast, and structure to better match human visual perception [Wang et al., 2004] [Brunet et al., 2011].
Methods
Initialize the SSIM module.
Compute SSIM with mean and standard deviation.
Calculate SSIM between predicted and target images.
- __init__(data_range: float = 1.0, kernel_size: int = 11, sigma: float = 1.5, reduction: str | None = None, *args: Any, **kwargs: Any) None[source]
Initialize the SSIM module.
- Parameters:
data_range (float) – Range of the input data (typically 1.0 or 255)
kernel_size (int) – Size of the Gaussian kernel
sigma (float) – Standard deviation of the Gaussian kernel
reduction (Optional[str]) – Reduction method. The underlying torchmetrics implementation requires reduction=None, so this parameter controls post-processing reduction.
*args – Variable length argument list passed to the base class and torchmetrics.
**kwargs – Arbitrary keyword arguments passed to the base class and torchmetrics.
- forward(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) Tensor[source]
Calculate SSIM between predicted and target images.
- Parameters:
x (Tensor) – Predicted images
y (Tensor) – Target images
*args – Variable length argument list (currently unused).
**kwargs – Arbitrary keyword arguments (currently unused).
- Returns:
SSIM values for each sample or reduced according to reduction parameter
- Return type:
Tensor
- compute_with_stats(x: Tensor, y: Tensor, *args: Any, **kwargs: Any) Tuple[Tensor, Tensor][source]
Compute SSIM with mean and standard deviation.
- Parameters:
x (Tensor) – Predicted images
y (Tensor) – Target images
*args – Variable length argument list (currently unused).
**kwargs – Arbitrary keyword arguments (currently unused).
- Returns:
Mean and standard deviation of SSIM values
- Return type:
Tuple[Tensor, Tensor]