pyiqa.archs.lpips_arch ====================== .. py:module:: pyiqa.archs.lpips_arch .. autoapi-nested-parse:: 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 --------------- .. py:data:: default_model_urls .. py:function:: upsample(in_tens, out_HW=(64, 64)) .. py:function:: spatial_average(in_tens, keepdim=True) .. py:function:: normalize_tensor(in_feat, eps=1e-10) .. py:class:: 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) Bases: :py:obj:`torch.nn.Module` LPIPS 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. :type pretrained: Boolean :param pnet_rand: Whether to randomly initialized trunk. :type pnet_rand: Boolean :param net: ['alex','vgg','squeeze'] are the base/trunk networks available. :type net: String :param version: choose the version ['v0.1'] is the default and latest; ['v0.0'] contained a normalization bug. :type version: String :param pretrained_model_path: Petrained model path. :type pretrained_model_path: String :param The following parameters should only be changed if training the network: :param eval_mode: choose the mode; True is for test mode (default). :type eval_mode: Boolean :param pnet_tune: Whether to tune the base/trunk network. :type pnet_tune: Boolean :param use_dropout: Whether to use dropout when training linear layers. :type use_dropout: Boolean .. py:method:: forward(in1, in0, retPerLayer=False, normalize=True) Computation IQA using LPIPS. :param in1: An input tensor. Shape :math:`(N, C, H, W)`. :param in0: A reference tensor. Shape :math:`(N, C, H, W)`. :param retPerLayer: return result contains result of each layer or not. Default: False. :type retPerLayer: Boolean :param normalize: Whether to normalize image data range in [0,1] to [-1,1]. Default: True. :type normalize: Boolean :returns: Quality score. .. py:class:: ScalingLayer Bases: :py:obj:`torch.nn.Module` .. py:method:: forward(inp) .. py:class:: NetLinLayer(chn_in, chn_out=1, use_dropout=False) Bases: :py:obj:`torch.nn.Module` A single linear layer which does a 1x1 conv .. py:method:: forward(x) .. py:class:: squeezenet(requires_grad=False, pretrained=True) Bases: :py:obj:`torch.nn.Module` .. py:method:: forward(X) .. py:class:: alexnet(requires_grad=False, pretrained=True) Bases: :py:obj:`torch.nn.Module` .. py:method:: forward(X) .. py:class:: vgg16(requires_grad=False, pretrained=True) Bases: :py:obj:`torch.nn.Module` .. py:method:: forward(X) .. py:class:: resnet(requires_grad=False, pretrained=True, num=18) Bases: :py:obj:`torch.nn.Module` .. py:method:: forward(X)