pyiqa.archs.compare2score_arch

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

pyiqa.archs.compare2score_arch.expand2square(pil_img)[source]

Pad a PIL image to square with CLIP-mean background color.

Parameters:

pil_img (PIL.Image.Image) – Input image.

Returns:

Square padded image.

Return type:

PIL.Image.Image

class pyiqa.archs.compare2score_arch.Compare2Score(dtype='fp16')[source]

Bases: torch.nn.Module

Compare2Score large multimodal IQA model wrapper.

Parameters:

dtype (str) – Inference precision mode. Supported values are 'fp16', '4bit', and '8bit'.

Notes

Current implementation supports batch size 1 in preprocessing.

preprocess(x)[source]

Convert a single-image tensor batch to PIL image.

Parameters:

x (torch.Tensor) – Input tensor with shape (1, 3, H, W).

Returns:

Converted image.

Return type:

PIL.Image.Image

Raises:

AssertionError – If batch size is not 1.

forward(x)[source]

Run Compare2Score model inference.

Parameters:

x (torch.Tensor) – Input image tensor with shape (1, 3, H, W).

Returns:

Predicted quality score.

Return type:

torch.Tensor