pyiqa.archs.msswd_arch

Perceptual color difference metric, MS-SWD.

@inproceedings{he2024ms-swd,

title={Multiscale Sliced {Wasserstein} Distances as Perceptual Color Difference Measures}, author={He, Jiaqi and Wang, Zhihua and Wang, Leon and Liu, Tsein-I and Fang, Yuming and Sun, Qilin and Ma, Kede}, booktitle={European Conference on Computer Vision}, pages={1–18}, year={2024}, url={http://arxiv.org/abs/2407.10181}

}

Reference:

Module Contents

pyiqa.archs.msswd_arch.color_space_transform(input_color, fromSpace2toSpace)[source]

Transform color tensors between supported color spaces.

Parameters:
  • input_color (torch.Tensor) – Color tensor with shape (N, C, H, W).

  • fromSpace2toSpace (str) – Conversion key, for example 'srgb2lab'.

Returns:

Transformed tensor with shape (N, C, H, W).

Return type:

torch.Tensor

Raises:

ValueError – If the conversion key is not defined.

class pyiqa.archs.msswd_arch.MS_SWD_learned(resize_input: bool = True, pretrained: bool = True, pretrained_model_path: str = None, **kwargs)[source]

Bases: torch.nn.Module

MS-SWD perceptual color difference metric.

Parameters:
  • resize_input (bool) – Whether to resize inputs with short side larger than 256 before scoring.

  • pretrained (bool) – Whether to load pretrained weights.

  • pretrained_model_path (str | None) – Optional local checkpoint path.

  • **kwargs – Reserved compatibility arguments.

preprocess_img(x)[source]

Optionally resize image batch before feature extraction.

forward_once(x)[source]

Encode one image batch into sorted SWD feature representation.

forward(x, y)[source]

Compute MS-SWD distance.

Parameters:
  • x (torch.Tensor) – Distorted image tensor with shape (N, 3, H, W).

  • y (torch.Tensor) – Reference image tensor with shape (N, 3, H, W).

Returns:

Distance scores with shape (N,).

Return type:

torch.Tensor