Github Repo • ? Twitter • ? Paper ImageReward is the first geeral-purpose text-to-image huma preferece RM which is traied o i total 137k pairs of
expert comparisos, based o text prompts ad correspodig model outputs from DiffusioDB. We demostrate that
ImageReward outperforms existig text-image scorig methods, such as CLIP, Aesthetic, ad BLIP, i terms of
uderstadig huma preferece i text-to-image sythesis through extesive aalysis ad experimets. We have itegrated the whole repository to a sigle pytho package We provide example images i the Use the followig code to get the huma preferece scores from ImageReward: The output should be like as follow (the exact umbers may be slightly differet depedig o the compute device):ImageReward
Quick Start
Istall Depedecy
image-reward
. Followig the commads below to prepare the eviromet:# Cloe the ImageReward repository (cotaiig data for testig)
git cloe https://github.com/THUDM/ImageReward.git
cd ImageReward
# Istall the itegrated package `image-reward`
pip istall image-reward
Example Use
assets/images
directory of this repo. The example prompt is:a paitig of a ocea with clouds ad birds, day time, low depth field effect
import os
import torch
import ImageReward as reward
if __ame__ == "__mai__":
prompt = "a paitig of a ocea with clouds ad birds, day time, low depth field effect"
img_prefix = "assets/images"
geeratios = [f"{pic_id}.webp" for pic_id i rage(1, 5)]
img_list = [os.path.joi(img_prefix, img) for img i geeratios]
model = reward.load("ImageReward-v1.0")
with torch.o_grad():
rakig, rewards = model.iferece_rak(prompt, img_list)
# Prit the result
prit("\Preferece predictios:\")
prit(f"rakig = {rakig}")
prit(f"rewards = {rewards}")
for idex i rage(le(img_list)):
score = model.score(prompt, img_list[idex])
prit(f"{geeratios[idex]:>16s}: {score:.2f}")
Preferece predictios:
rakig = [1, 2, 3, 4]
rewards = [[0.5811622738838196], [0.2745276093482971], [-1.4131819009780884], [-2.029569625854492]]
1.webp: 0.58
2.webp: 0.27
3.webp: -1.41
4.webp: -2.03
Citatio
@misc{xu2023imagereward,
title={ImageReward: Learig ad Evaluatig Huma Prefereces for Text-to-Image Geeratio},
author={Jiazheg Xu ad Xiao Liu ad Yuche Wu ad Yuxua Tog ad Qikai Li ad Mig Dig ad Jie Tag ad Yuxiao Dog},
year={2023},
eprit={2304.05977},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
点击空白处退出提示
评论