pyiqa.archs.compare2score_arch ============================== .. py:module:: pyiqa.archs.compare2score_arch .. autoapi-nested-parse:: Adaptive Image Quality Assessment via Teaching Large Multimodal Model to Compare Reference: @inproceedings{zhu2024adaptive, title={Adaptive Image Quality Assessment via Teaching Large Multimodal Model to Compare}, author={Zhu, Hanwei and Wu, Haoning and Li, Yixuan and Zhang, Zicheng and Chen, Baoliang and Zhu, Lingyu and Fang, Yuming and Zhai, Guangtao and Lin, Weisi and Wang, Shiqi}, booktitle={Conference on Neural Information Processing Systems}, year={2024}, } Reference url: https://github.com/Q-Future/Compare2Score Module Contents --------------- .. py:function:: expand2square(pil_img) Pad a PIL image to square with CLIP-mean background color. :param pil_img: Input image. :type pil_img: PIL.Image.Image :returns: Square padded image. :rtype: PIL.Image.Image .. py:class:: Compare2Score(dtype='fp16') Bases: :py:obj:`torch.nn.Module` Compare2Score large multimodal IQA model wrapper. :param dtype: Inference precision mode. Supported values are ``'fp16'``, ``'4bit'``, and ``'8bit'``. :type dtype: str .. rubric:: Notes Current implementation supports batch size ``1`` in preprocessing. .. py:method:: preprocess(x) Convert a single-image tensor batch to PIL image. :param x: Input tensor with shape ``(1, 3, H, W)``. :type x: torch.Tensor :returns: Converted image. :rtype: PIL.Image.Image :raises AssertionError: If batch size is not ``1``. .. py:method:: forward(x) Run Compare2Score model inference. :param x: Input image tensor with shape ``(1, 3, H, W)``. :type x: torch.Tensor :returns: Predicted quality score. :rtype: torch.Tensor