kaira.metrics.image.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:
BaseMetricPeak 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
Initialize the PeakSignalNoiseRatio module.
Compute PSNR with mean and standard deviation.
Calculate PSNR between predicted and target images.
- __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]