kaira.metrics.image.PeakSignalNoiseRatio

Inheritance diagram of PeakSignalNoiseRatio

Inheritance diagram for PeakSignalNoiseRatio

class kaira.metrics.image.PeakSignalNoiseRatio(data_range: float = 1.0, reduction: str | None = None, *args: Any, **kwargs: Any)[source]

Bases: BaseMetric

Peak Signal-to-Noise Ratio (PSNR) Module.

PSNR measures the ratio between the maximum possible power of a signal and the power of corrupting noise that affects the quality of its representation. Higher values indicate better quality [Hore and Ziou, 2010]. While PSNR doesn’t perfectly correlate with human perception, it is widely used for its simplicity and clear physical meaning [Wang and Bovik, 2009].

Methods

__init__

Initialize the PeakSignalNoiseRatio module.

compute_with_stats

Compute PSNR with mean and standard deviation.

forward

Calculate PSNR between predicted and target images.

Examples using kaira.metrics.image.PeakSignalNoiseRatio

Image Quality Metrics

Image Quality Metrics

Original DeepJSCC Model (Bourtsoulatze 2019) with Training

Original DeepJSCC Model (Bourtsoulatze 2019) with Training

Deep Joint Source-Channel Coding (DeepJSCC) Model - Bourtsoulatze2019 Implementation

Deep Joint Source-Channel Coding (DeepJSCC) Model - Bourtsoulatze2019 Implementation
__init__(data_range: float = 1.0, reduction: str | None = None, *args: Any, **kwargs: Any) None[source]

Initialize the PeakSignalNoiseRatio module.

Parameters:
  • data_range (float) – The range of the input data (typically 1.0 or 255)

  • 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 PSNR 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:

PSNR 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 PSNR 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 PSNR values

Return type:

Tuple[Tensor, Tensor]