🚀 Compare2Score模型
Compare2Score模型可用于图像质量评估,通过特定的算法为图像给出质量评分,为图像质量的量化提供了有效的解决方案。
🚀 快速开始
使用AutoModel快速启动
可以使用transformers
库中的AutoModel
来快速启动模型。以下是一个示例代码,展示了如何使用AutoModelForCausalLM
加载模型并对图像进行评分:
import requests
import torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("q-future/Compare2Score", trust_remote_code=True, attn_implementation="eager",
torch_dtype=torch.float16, device_map="auto")
from PIL import Image
image_path_url = "https://raw.githubusercontent.com/Q-Future/Q-Align/main/fig/singapore_flyer.jpg"
print("The quality score of this image is {}".format(model.score(image_path_url)))
在GitHub上进行评估
如果你想在本地对模型进行评估,可以按照以下步骤操作:
git clone https://github.com/Q-Future/Compare2Score.git
cd Compare2Score
pip install -e .
安装完成后,你可以使用以下代码对图像进行评分:
from q_align import Compare2Scorer
from PIL import Image
scorer = Compare2Scorer()
image_path = "figs/i04_03_4.bmp"
print("The quality score of this image is {}.".format(scorer(image_path)))
📚 引用
如果你使用了该模型,请引用以下论文:
@article{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},
journal={arXiv preprint arXiv:2405.19298},
year={2024},
}
📄 许可证
本项目采用MIT许可证。