| --- |
| frameworks: |
| - Pytorch |
| license: apache-2.0 |
| tags: [] |
| tasks: |
| - text-to-image-synthesis |
| --- |
| |
| # 图像质量评估模型 |
|
|
|
|
| 本仓库包含了接入 [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio) 的多款主流图像质量评估模型权重。支持图文语义对齐、人类视觉偏好、纯图像美学以及数据集分布等多个维度的评测。 |
|
|
| ## 评估效果效果展示 |
|
|
| > **prompt**: A cat is sitting on a stone. |
|
|
| | 评估指标 |  |  | |
| |:---:|:---:|:---:| |
| | Pickscore | 22.958 | **23.321** | |
| | ImageReward | 1.419 | **1.786** | |
| | HPSv2 | 30.169 | **30.528** | |
| | HPSv3 | 12.287 | **12.969** | |
| | CLIP Score | **40.271** | 39.065 | |
| | Aesthetic | 5.096 | **5.848** | |
| | UnifiedReward | 'alignment': 4.5, 'coherence': 4.0, 'style': 3.5 | 'alignment': 4.0, 'coherence': 4.0, 'style': 3.5 | |
|
|
| --- |
|
|
| ## 指标总览 |
|
|
| |指标名称|输入要求|输出结果| |
| |-|-|-| |
| |PickScore|prompt + PIL 图像|人类视觉偏好分数| |
| |ImageReward|prompt + PIL 图像|人类视觉偏好分数| |
| |HPSv2|prompt + PIL 图像|人类视觉偏好分数| |
| |HPSv3|prompt + PIL 图像|人类视觉偏好分数| |
| |CLIP Score|prompt + PIL 图像|图文相似度| |
| |Aesthetic|PIL 图像|美学分数| |
| |UnifiedReward|prompt + PIL 图像|多维评分| |
| |FID|参考图目录 + 生成图目录|分布距离| |
|
|
|
|
| ## 快速使用 |
|
|
| * 安装 [DiffSynth-Studio](https://github.com/modelscope/DiffSynth-Studio) |
|
|
| ``` |
| git clone https://github.com/modelscope/DiffSynth-Studio.git |
| cd DiffSynth-Studio |
| pip install -e . |
| ``` |
|
|
| * 示例 1:使用 PickScore 评估图文偏好 |
|
|
| ```python |
| from diffsynth.metrics import PickScoreMetric, ModelConfig |
| from modelscope import dataset_snapshot_download |
| from PIL import Image |
| |
| dataset_snapshot_download( |
| "DiffSynth-Studio/diffsynth_example_dataset", |
| allow_file_pattern="flux/FLUX.1-dev/*", |
| local_dir="./data/diffsynth_example_dataset", |
| ) |
| image = Image.open("data/diffsynth_example_dataset/flux/FLUX.1-dev/1.jpg").convert("RGB") |
| prompt = "a dog" |
| metric = PickScoreMetric.from_pretrained( |
| model_config=ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="PickScore/model.safetensors"), |
| device="cuda" |
| ) |
| score = metric.compute(prompt, image)[0] |
| print(f"PickScore score:: {score:.3f}") |
| ``` |
|
|
| * 示例 2:使用 Aesthetic 评估纯美学质量 |
|
|
| ```python |
| from diffsynth.metrics import AestheticMetric, ModelConfig |
| from modelscope import dataset_snapshot_download |
| from PIL import Image |
| |
| dataset_snapshot_download( |
| "DiffSynth-Studio/diffsynth_example_dataset", |
| allow_file_pattern="flux/FLUX.1-dev/*", |
| local_dir="./data/diffsynth_example_dataset", |
| ) |
| image = Image.open("data/diffsynth_example_dataset/flux/FLUX.1-dev/1.jpg").convert("RGB") |
| metric = AestheticMetric.from_pretrained( |
| model_config=ModelConfig(model_id="DiffSynth-Studio/ImageMetrics", origin_file_pattern="Aesthetic/model.safetensors"), |
| device="cuda" |
| ) |
| score = metric.compute(image)[0] |
| print(f"Aesthetic score: {score:.3f}") |
| ``` |
|
|
| 关于所有指标的详细使用方法和说明,请参考 DiffSynth-Studio 的相关[文档](https://github.com/modelscope/DiffSynth-Studio/blob/main/docs/zh/Model_Details/Image-Quality-Metrics.md)。 |
|
|