pyiqa.archs.lpips_arch¶
LPIPS Model.
Created by: https://github.com/richzhang/PerceptualSimilarity.
Modified by: Jiadi Mo (https://github.com/JiadiMo)
- Reference:
Zhang, Richard, et al. “The unreasonable effectiveness of deep features as a perceptual metric.” Proceedings of the IEEE conference on computer vision and pattern recognition. 2018.
TOPIQ: A Top-down Approach from Semantics to Distortions for Image Quality Assessment. Chaofeng Chen, Jiadi Mo, Jingwen Hou, Haoning Wu, Liang Liao, Wenxiu Sun, Qiong Yan, Weisi Lin. Transactions on Image Processing, 2024.
Module Contents¶
- class pyiqa.archs.lpips_arch.LPIPS(pretrained=True, net='alex', version='0.1', lpips=True, spatial=False, pnet_rand=False, pnet_tune=False, use_dropout=True, pretrained_model_path=None, eval_mode=True, semantic_weight_layer=-1, **kwargs)[source]¶
Bases:
torch.nn.ModuleLPIPS model. :param lpips: Whether to use linear layers on top of base/trunk network. :type lpips: Boolean :param pretrained: Whether means linear layers are calibrated with human
perceptual judgments.
- Parameters:
pnet_rand (Boolean) – Whether to randomly initialized trunk.
net (String) – [‘alex’,’vgg’,’squeeze’] are the base/trunk networks available.
version (String) – choose the version [‘v0.1’] is the default and latest; [‘v0.0’] contained a normalization bug.
pretrained_model_path (String) – Petrained model path.
network (The following parameters should only be changed if training the)
eval_mode (Boolean) – choose the mode; True is for test mode (default).
pnet_tune (Boolean) – Whether to tune the base/trunk network.
use_dropout (Boolean) – Whether to use dropout when training linear layers.
- forward(in1, in0, retPerLayer=False, normalize=True)[source]¶
Computation IQA using LPIPS. :param in1: An input tensor. Shape \((N, C, H, W)\). :param in0: A reference tensor. Shape \((N, C, H, W)\). :param retPerLayer: return result contains result of
each layer or not. Default: False.
- Parameters:
normalize (Boolean) – Whether to normalize image data range in [0,1] to [-1,1]. Default: True.
- Returns:
Quality score.
- class pyiqa.archs.lpips_arch.NetLinLayer(chn_in, chn_out=1, use_dropout=False)[source]¶
Bases:
torch.nn.ModuleA single linear layer which does a 1x1 conv
- class pyiqa.archs.lpips_arch.squeezenet(requires_grad=False, pretrained=True)[source]¶
Bases:
torch.nn.Module
- class pyiqa.archs.lpips_arch.alexnet(requires_grad=False, pretrained=True)[source]¶
Bases:
torch.nn.Module