pyiqa.archs.clipiqa_arch ======================== .. py:module:: pyiqa.archs.clipiqa_arch .. autoapi-nested-parse:: CLIP-IQA metric, proposed by Exploring CLIP for Assessing the Look and Feel of Images. Jianyi Wang, Kelvin C.K. Chan, Chen Change Loy. AAAI 2023. Ref url: https://github.com/IceClear/CLIP-IQA Re-implemented by: Chaofeng Chen (https://github.com/chaofengc) with the following modification: - We assemble multiple prompts to improve the results of clipiqa model. Module Contents --------------- .. py:data:: default_model_urls .. py:class:: PromptLearner(clip_model, n_ctx=16) Bases: :py:obj:`torch.nn.Module` PromptLearner class for learning prompts for CLIP-IQA. Disclaimer: This implementation follows exactly the official codes in: https://github.com/IceClear/CLIP-IQA. We have no idea why some tricks are implemented like this, which include: 1. Using n_ctx prefix characters "X" 2. Appending extra "." at the end 3. Insert the original text embedding at the middle .. py:method:: get_prompts_with_middle_class() Get prompts with the original text embedding inserted in the middle. :returns: The generated prompts. :rtype: torch.Tensor .. py:method:: forward(clip_model) Forward pass for the PromptLearner. :param clip_model: The CLIP model. :type clip_model: nn.Module :returns: The output features. :rtype: torch.Tensor .. py:class:: CLIPIQA(model_type='clipiqa', backbone='RN50', pretrained=True, pos_embedding=False) Bases: :py:obj:`torch.nn.Module` CLIPIQA metric class. :param model_type: The type of the model. Default is 'clipiqa'. :type model_type: str :param backbone: The backbone model. Default is 'RN50'. :type backbone: str :param pretrained: Whether to load pretrained weights. Default is True. :type pretrained: bool :param pos_embedding: Whether to use positional embedding. Default is False. :type pos_embedding: bool .. py:method:: forward(x) Forward pass for the CLIPIQA model. :param x: Input tensor with shape (N, C, H, W). :type x: torch.Tensor :returns: The output probabilities. :rtype: torch.Tensor