自学内容网 自学内容网

【VQAScore 文本生成质量评估 测试代码】

## 安装环境

!pip install t2v-metrics==1.1 clip torch

## 测试代码

from t2v_metrics import VQAScore

model_name = ["clip-flant5-xxl", "clip-flant5-xl"][0]
# text = "Two dogs of different breeds playfully chasing around a tree"
text = "Two dogs of the same breed playing on the grass"
images = [
    "images/DALLE3.png", 
    "images/DeepFloyd.jpg",
    "images/Midjourney.jpg",
    "images/SDXL.jpg"
]
model_pipe = VQAScore(model=model_name, device="cuda")
results = model_pipe(images=images, texts=[text]).cpu()[:, 0].tolist()
ranked_results = sorted(zip(images, results), key=lambda x: x[1], reverse=True)
ranked_images = [
    (img, f"Rank: {rank + 1} - Score: {score:.2f}")
    for rank, (img, score) in enumerate(ranked_results)
]
print("Ranked Results:", ranked_results)

## 数据集

HF: BaiqiL/GenAI-Bench


原文地址:https://blog.csdn.net/qq_39749966/article/details/143576377

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!