mirror of
https://github.com/modelscope/DiffSynth-Studio.git
synced 2026-03-24 01:48:13 +00:00
update preference models
This commit is contained in:
23
examples/image_quality_metric/image_quality_evaluation.py
Normal file
23
examples/image_quality_metric/image_quality_evaluation.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from diffsynth.extensions.ImageQualityMetric import download_preference_model, load_preference_model
|
||||
from modelscope import dataset_snapshot_download
|
||||
from PIL import Image
|
||||
|
||||
|
||||
# Download example image
|
||||
dataset_snapshot_download(
|
||||
dataset_id="DiffSynth-Studio/examples_in_diffsynth",
|
||||
allow_file_pattern="data/examples/ImageQualityMetric/image.jpg",
|
||||
local_dir="./"
|
||||
)
|
||||
|
||||
# Parameters
|
||||
prompt = "an orange cat"
|
||||
image = Image.open("data\examples\ImageQualityMetric\image.jpg")
|
||||
device = "cuda"
|
||||
cache_dir = "./models"
|
||||
|
||||
# Run preference models
|
||||
for model_name in ["ImageReward", "Aesthetic", "PickScore", "CLIP", "HPSv2", "HPSv2.1", "MPS"]:
|
||||
path = download_preference_model(model_name, cache_dir=cache_dir)
|
||||
preference_model = load_preference_model(model_name, device=device, path=path)
|
||||
print(model_name, preference_model.score(image, prompt))
|
||||
Reference in New Issue
Block a user