piqa.haarpsi#
Haar Perceptual Similarity Index (HaarPSI)
This module implements the HaarPSI in PyTorch.
Original
https://github.com/rgcda/haarpsi
Wikipedia
https://wikipedia.org/wiki/Haar_wavelet
References
A Haar Wavelet-Based Perceptual Similarity Index for Image Quality Assessment (Reisenhofer et al., 2018)
Functions#
Returns the HaarPSI between \(x\) and \(y\), without color space conversion. |
Classes#
Measures the HaarPSI between an input and a target. |
Descriptions#
- piqa.haarpsi.haarpsi(x, y, n_kernels=3, value_range=1.0, c=0.000461361014994233, alpha=4.2)#
Returns the HaarPSI between \(x\) and \(y\), without color space conversion.
- Parameters:
Note
For the remaining arguments, refer to Reisenhofer et al. (2018).
- Returns:
The HaarPSI vector, \((N,)\).
- Return type:
Example
>>> x = torch.rand(5, 3, 256, 256) >>> y = torch.rand(5, 3, 256, 256) >>> l = haarpsi(x, y) >>> l.shape torch.Size([5])
- class piqa.haarpsi.HaarPSI(chromatic=True, downsample=True, reduction='mean', **kwargs)#
Measures the HaarPSI between an input and a target.
Before applying
haarpsi
, the input and target are converted from RBG to Y(IQ) and downsampled by a factor 2.- Parameters:
Example
>>> criterion = HaarPSI() >>> x = torch.rand(5, 3, 256, 256, requires_grad=True) >>> y = torch.rand(5, 3, 256, 256) >>> l = 1 - criterion(x, y) >>> l.shape torch.Size([]) >>> l.backward()