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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div align="center">
|
| 2 |
+
|
| 3 |
+
# HPSv3: Towards Wide-Spectrum Human Preference Score (ICCV 2025)
|
| 4 |
+
|
| 5 |
+
[](https://mizzenai.github.io/HPSv3.project/)
|
| 6 |
+
[](https://arxiv.org/abs/2508.03789)
|
| 7 |
+
[](https://arxiv.org/abs/2508.03789)
|
| 8 |
+
[](https://huggingface.co/MizzenAI/HPSv3)
|
| 9 |
+
[](https://huggingface.co/datasets/MizzenAI/HPDv3)
|
| 10 |
+
[](https://pypi.org/project/hpsv3/)
|
| 11 |
+
|
| 12 |
+
**Yuhang Ma**<sup>1,3*</sup>  **Yunhao Shui**<sup>1,4*</sup>  **Xiaoshi Wu**<sup>2</sup>  **Keqiang Sun**<sup>1,2†</sup>  **Hongsheng Li**<sup>2,5,6†</sup>
|
| 13 |
+
|
| 14 |
+
<sup>1</sup>Mizzen AI   <sup>2</sup>CUHK MMLab   <sup>3</sup>King’s College London   <sup>4</sup>Shanghai Jiaotong University  
|
| 15 |
+
|
| 16 |
+
<sup>5</sup>Shanghai AI Laboratory   <sup>6</sup>CPII, InnoHK  
|
| 17 |
+
|
| 18 |
+
<sup>*</sup>Equal Contribution  <sup>†</sup>Equal Advising
|
| 19 |
+
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
## 📖 Introduction
|
| 24 |
+
|
| 25 |
+
This is the official implementation for the paper: [HPSv3: Towards Wide-Spectrum Human Preference Score](https://arxiv.org/abs/2508.03789).
|
| 26 |
+
First, we introduce a VLM-based preference model **HPSv3**, trained on a "wide spectrum" preference dataset **HPDv3** with 1.08M text-image pairs and 1.17M annotated pairwise comparisons, covering both state-of-the-art and earlier generative models, as well as high- and low-quality real-world images. Second, we propose a novel reasoning approach for iterative image refinement, **CoHP(Chain-of-Human-Preference)**, which efficiently improves image quality without requiring additional training data.
|
| 27 |
+
|
| 28 |
+
<p align="center">
|
| 29 |
+
<img src="assets/teaser.png" alt="Teaser" width="900"/>
|
| 30 |
+
</p>
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
## ✨ Updates
|
| 34 |
+
- **[2025-08-08]** 🎉 We release [HPDv3](https://huggingface.co/datasets/MizzenAI/HPDv3) dataset!.
|
| 35 |
+
- **[2025-08-06]** 🎉 We release HPSv3: inference code, training code, cohp code and [HPSv3 model weights](https://huggingface.co/MizzenAI/HPSv3). And [PyPI Package](https://pypi.org/project/hpsv3/).
|
| 36 |
+
|
| 37 |
+
## 📑 Table of Contents
|
| 38 |
+
1. [🚀 Quick Start](#🚀-quick-start)
|
| 39 |
+
2. [🌐 Gradio Demo](#🌐-gradio-demo)
|
| 40 |
+
3. [🏋️ Training](#🏋️-training)
|
| 41 |
+
4. [📊 Benchmark](#📊-benchmark)
|
| 42 |
+
5. [🎯 CoHP (Chain-of-Human-Preference)](#🎯-cohp-chain-of-human-preference)
|
| 43 |
+
|
| 44 |
+
---
|
| 45 |
+
|
| 46 |
+
## 🚀 Quick Start
|
| 47 |
+
|
| 48 |
+
HPSv3 is a state-of-the-art human preference score model for evaluating image quality and prompt alignment. It builds upon the Qwen2-VL architecture to provide accurate assessments of generated images.
|
| 49 |
+
|
| 50 |
+
### 💻 Installation
|
| 51 |
+
|
| 52 |
+
<!-- # Method 1: Pypi download and install for inference.
|
| 53 |
+
pip install hpsv3 -->
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
# Method 1: Pypi download and install for inference.
|
| 57 |
+
pip install hpsv3
|
| 58 |
+
|
| 59 |
+
# Method 2: Install locally for development or training.
|
| 60 |
+
git clone https://github.com/MizzenAI/HPSv3.git
|
| 61 |
+
cd HPSv3
|
| 62 |
+
|
| 63 |
+
conda env create -f environment.yaml
|
| 64 |
+
conda activate hpsv3
|
| 65 |
+
# Recommend: Install flash-attn
|
| 66 |
+
pip install flash-attn==2.7.4.post1
|
| 67 |
+
|
| 68 |
+
pip install -e .
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
### 🛠️ Basic Usage
|
| 72 |
+
|
| 73 |
+
#### Simple Inference Example
|
| 74 |
+
|
| 75 |
+
```python
|
| 76 |
+
from hpsv3 import HPSv3RewardInferencer
|
| 77 |
+
|
| 78 |
+
# Initialize the model
|
| 79 |
+
inferencer = HPSv3RewardInferencer(device='cuda')
|
| 80 |
+
|
| 81 |
+
# Evaluate images
|
| 82 |
+
image_paths = ["assets/example1.png", "assets/example2.png"]
|
| 83 |
+
prompts = [
|
| 84 |
+
"cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker",
|
| 85 |
+
"cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker"
|
| 86 |
+
]
|
| 87 |
+
|
| 88 |
+
# Get preference scores
|
| 89 |
+
rewards = inferencer.reward(image_paths, prompts)
|
| 90 |
+
scores = [reward[0].item() for reward in rewards] # Extract mu values
|
| 91 |
+
print(f"Image scores: {scores}")
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## 🌐 Gradio Demo
|
| 97 |
+
|
| 98 |
+
Launch an interactive web interface to test HPSv3:
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
python gradio_demo/demo.py
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
The demo will be available at `http://localhost:7860` and provides:
|
| 105 |
+
|
| 106 |
+
<p align="left">
|
| 107 |
+
<img src="assets/gradio.png" alt="Gradio Demo" width="500"/>
|
| 108 |
+
</p>
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
## 📁 Dataset
|
| 113 |
+
|
| 114 |
+
### Human Preference Dataset v3
|
| 115 |
+
|
| 116 |
+
Human Preference Dataset v3 (HPD v3) comprises 1.08M text-image pairs and 1.17M annotated pairwise data. To modeling the wide spectrum of human preference, we introduce newest state-of-the-art generative models and high quality real photographs while maintaining old models and lower quality real images.
|
| 117 |
+
<p align="left">
|
| 118 |
+
<img src="assets/datasetvisual_0.jpg" alt="dataset" width="500"/>
|
| 119 |
+
</p>
|
| 120 |
+
<details close>
|
| 121 |
+
<summary>Detail information of HPD v3</summary>
|
| 122 |
+
|
| 123 |
+
| Image Source | Type | Num Image | Prompt Source | Split |
|
| 124 |
+
|--------------|------|-----------|---------------|-------|
|
| 125 |
+
| High Quality Image (HQI) | Real Image | 57759 | VLM Caption | Train & Test |
|
| 126 |
+
| MidJourney | - | 331955 | User | Train |
|
| 127 |
+
| CogView4 | DiT | 400 | HQI+HPDv2+JourneyDB | Test |
|
| 128 |
+
| FLUX.1 dev | DiT | 48927 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 129 |
+
| Infinity | Autoregressive | 27061 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 130 |
+
| Kolors | DiT | 49705 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 131 |
+
| HunyuanDiT | DiT | 46133 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 132 |
+
| Stable Diffusion 3 Medium | DiT | 49266 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 133 |
+
| Stable Diffusion XL | Diffusion | 49025 | HQI+HPDv2+JourneyDB | Train & Test |
|
| 134 |
+
| Pixart Sigma | Diffusion | 400 | HQI+HPDv2+JourneyDB | Test |
|
| 135 |
+
| Stable Diffusion 2 | Diffusion | 19124 | HQI+JourneyDB | Train & Test |
|
| 136 |
+
| CogView2 | Autoregressive | 3823 | HQI+JourneyDB | Train & Test |
|
| 137 |
+
| FuseDream | Diffusion | 468 | HQI+JourneyDB | Train & Test |
|
| 138 |
+
| VQ-Diffusion | Diffusion | 18837 | HQI+JourneyDB | Train & Test |
|
| 139 |
+
| Glide | Diffusion | 19989 | HQI+JourneyDB | Train & Test |
|
| 140 |
+
| Stable Diffusion 1.4 | Diffusion | 18596 | HQI+JourneyDB | Train & Test |
|
| 141 |
+
| Stable Diffusion 1.1 | Diffusion | 19043 | HQI+JourneyDB | Train & Test |
|
| 142 |
+
| Curated HPDv2 | - | 327763 | - | Train |
|
| 143 |
+
</details>
|
| 144 |
+
|
| 145 |
+
### Download HPDv3
|
| 146 |
+
<!-- ```
|
| 147 |
+
HPDv3 is comming soon! Stay tuned!
|
| 148 |
+
``` -->
|
| 149 |
+
```bash
|
| 150 |
+
huggingface-cli download --repo-type dataset MizzenAI/HPDv3 --local-dir /your-local-dataset-path
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
### Pairwise Training Data Format
|
| 154 |
+
|
| 155 |
+
**Important Note: For simplicity, path1's image is always the prefered one**
|
| 156 |
+
|
| 157 |
+
#### All Annotated Pairs (`all.json`)
|
| 158 |
+
|
| 159 |
+
**Important Notes: In HPDv3, we simply put the preferred sample at the first place (path1)**
|
| 160 |
+
|
| 161 |
+
`all.json` contains **all** annotated pairs except for test.
|
| 162 |
+
|
| 163 |
+
```bash
|
| 164 |
+
[
|
| 165 |
+
# samples from HPDv3 annotation pipeline
|
| 166 |
+
{
|
| 167 |
+
"prompt": "Description of the visual content or the generation prompt.",
|
| 168 |
+
"choice_dist": [12, 7], # Distribution of votes from annotators (12 votes for image1, 7 votes for image2)
|
| 169 |
+
"confidence": 0.9999907, # Confidence score reflecting preference reliability, based on annotators' capabilities (independent of choice_dist)
|
| 170 |
+
"path1": "images/uuid1.jpg", # File path to the preferred image
|
| 171 |
+
"path2": "images/uuid2.jpg", # File path to the non-preferred image
|
| 172 |
+
"model1": "flux", # Model used to generate the preferred image (path1)
|
| 173 |
+
"model2": "infinity" # Model used to generate the non-preferred image (path2)
|
| 174 |
+
},
|
| 175 |
+
# samples from Midjourney
|
| 176 |
+
{
|
| 177 |
+
"prompt": "Description of the visual content or the generation prompt.",
|
| 178 |
+
"choice_dist": null, # No distribution of votes Information from Discord
|
| 179 |
+
"confidence": null, # No Confidence Information from Discord
|
| 180 |
+
"path1": "images/uuid1.jpg", # File path to the preferred image.
|
| 181 |
+
"path2": "images/uuid2.jpg", # File path to the non-preferred image.
|
| 182 |
+
"model1": "midjourney", # Comparsion between images generated from midjourney
|
| 183 |
+
"model2": "midjourney" # Comparsion between images generated from midjourney
|
| 184 |
+
},
|
| 185 |
+
# samples from Curated HPDv2
|
| 186 |
+
{
|
| 187 |
+
"prompt": "Description of the visual content or the generation prompt.",
|
| 188 |
+
"choice_dist": null, # No distribution of votes Information from the original HPDv2 traindataset
|
| 189 |
+
"confidence": null, # No Confidence Information from the original HPDv2 traindataset
|
| 190 |
+
"path1": "images/uuid1.jpg", # File path to the preferred image.
|
| 191 |
+
"path2": "images/uuid2.jpg", # File path to the non-preferred image.
|
| 192 |
+
"model1": "hpdv2", # No specific model name in the original HPDv2 traindataset, set to hpdv2
|
| 193 |
+
"model2": "hpdv2" # No specific model name in the original HPDv2 traindataset, set to hpdv2
|
| 194 |
+
},
|
| 195 |
+
]
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
#### Train set (`train.json`)
|
| 199 |
+
We sample part of training data from `all.json` to build training dataset `train.json`. Moreover, to improve robustness, we integrate random sampled part of data from [Pick-a-pic](https://huggingface.co/datasets/pickapic-anonymous/pickapic_v1) and [ImageRewardDB](https://huggingface.co/datasets/zai-org/ImageRewardDB), which is `pickapic.json` and `imagereward.json`. For these two datasets, we only provide the pair infomation, and its corresponding image can be found in their official dataset repository.
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
#### Test Set (`test.json`)
|
| 203 |
+
```bash
|
| 204 |
+
[
|
| 205 |
+
{
|
| 206 |
+
"prompt": "Description of the visual content",
|
| 207 |
+
"path1": "images/uuid1.jpg", # Preferred sample
|
| 208 |
+
"path2": "images/uuid2.jpg", # Unpreferred sample
|
| 209 |
+
"model1": "flux", # Model used to generate the preferred sample (path1).
|
| 210 |
+
"model2": "infinity", # Model used to generate the non-preferred sample (path2).
|
| 211 |
+
|
| 212 |
+
}
|
| 213 |
+
]
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
## 🏋️ Training
|
| 217 |
+
|
| 218 |
+
### 🚀 Training Command
|
| 219 |
+
|
| 220 |
+
```bash
|
| 221 |
+
# Use Method 2 to install locally
|
| 222 |
+
git clone https://github.com/MizzenAI/HPSv3.git
|
| 223 |
+
cd HPSv3
|
| 224 |
+
|
| 225 |
+
conda env create -f environment.yaml
|
| 226 |
+
conda activate hpsv3
|
| 227 |
+
# Recommend: Install flash-attn
|
| 228 |
+
pip install flash-attn==2.7.4.post1
|
| 229 |
+
|
| 230 |
+
pip install -e .
|
| 231 |
+
|
| 232 |
+
# Train with 7B model
|
| 233 |
+
deepspeed hpsv3/train.py --config hpsv3/config/HPSv3_7B.yaml
|
| 234 |
+
```
|
| 235 |
+
|
| 236 |
+
<details close>
|
| 237 |
+
<summary>Important Config Argument</summary>
|
| 238 |
+
|
| 239 |
+
| Configuration Section | Parameter | Value | Description |
|
| 240 |
+
|----------------------|-----------|-------|-------------|
|
| 241 |
+
| **Model Configuration** | `rm_head_type` | `"ranknet"` | Type of reward model head architecture |
|
| 242 |
+
| | `lora_enable` | `False` | Enable LoRA (Low-Rank Adaptation) for efficient fine-tuning. If `False`, language tower is fully trainable|
|
| 243 |
+
| | `vision_lora` | `False` | Apply LoRA specifically to vision components. If `False`, vision tower is fully trainable|
|
| 244 |
+
| | `model_name_or_path` | `"Qwen/Qwen2-VL-7B-Instruct"` | Path to the base model checkpoint |
|
| 245 |
+
| **Data Configuration** | `confidence_threshold` | `0.95` | Minimum confidence score for training data |
|
| 246 |
+
| | `train_json_list` | `[example_train.json]` | List of training data files |
|
| 247 |
+
| | `test_json_list` | `[validation_sets]` | List of validation datasets with names |
|
| 248 |
+
| | `output_dim` | `2` | Output dimension of the reward head for $\mu$ and $\sigma$|
|
| 249 |
+
| | `loss_type` | `"uncertainty"` | Loss function type for training |
|
| 250 |
+
</details>
|
| 251 |
+
|
| 252 |
---
|
| 253 |
+
|
| 254 |
+
## 📊 Benchmark
|
| 255 |
+
To evaluate **HPSv3 preference accuracy** or **human preference score of image generation model**, follow the detail instruction is in [Evaluate Insctruction](evaluate/README.md)
|
| 256 |
+
|
| 257 |
+
<details open>
|
| 258 |
+
<summary> Preference Accuracy of HPSv3 </summary>
|
| 259 |
+
|
| 260 |
+
| Model | ImageReward | Pickscore | HPDv2 | HPDv3 |
|
| 261 |
+
|------|-------------|-----------|-------|-------|
|
| 262 |
+
| [CLIP ViT-H/14](https://huggingface.co/laion/CLIP-ViT-H-14-laion2B-s32B-b79K) | 57.1 | 60.8 | 65.1 | 48.6 |
|
| 263 |
+
| [Aesthetic Score Predictor](https://github.com/christophschuhmann/improved-aesthetic-predictor) | 57.4 | 56.8 | 76.8 | 59.9 |
|
| 264 |
+
| [ImageReward](https://github.com/THUDM/ImageReward) | 65.1 | 61.1 | 74.0 | 58.6 |
|
| 265 |
+
| [PickScore](https://github.com/yuvalkirstain/PickScore) | 61.6 | <u>70.5</u> | 79.8 | <u>65.6</u> |
|
| 266 |
+
| [HPS](https://github.com/tgxs002/align_sd) | 61.2 | 66.7 | 77.6 | 63.8 |
|
| 267 |
+
| [HPSv2](https://github.com/tgxs002/HPSv2) | 65.7 | 63.8 | 83.3 | 65.3 |
|
| 268 |
+
| [MPS](https://github.com/Kwai-Kolors/MPS) | **67.5** | 63.1 | <u>83.5</u> | 64.3 |
|
| 269 |
+
| HPSv3 | <u>66.8</u> | **72.8** | **85.4** | **76.9** |
|
| 270 |
+
|
| 271 |
+
</details>
|
| 272 |
+
|
| 273 |
+
<details open>
|
| 274 |
+
<summary> Image Generation Benchmark of HPSv3 </summary>
|
| 275 |
+
|
| 276 |
+
| Model | Overall | Characters | Arts | Design | Architecture | Animals | Natural Scenery | Transportation | Products | Others | Plants | Food | Science |
|
| 277 |
+
|------|---------|------------|------|--------|--------------|---------|-----------------|----------------|----------|--------|--------|------|---------|
|
| 278 |
+
| **Kolors** | **10.55** | **11.79** | **10.47** | **9.87** | <u>10.82</u> | **10.60** | 9.89 | <u>10.68</u> | <u>10.93</u> | **10.50** | **10.63** | <u>11.06</u> | <u>9.51</u> |
|
| 279 |
+
| **Flux-dev** | <u>10.43</u> | <u>11.70</u> | <u>10.32</u> | 9.39 | **10.93** | <u>10.38</u> | <u>10.01</u> | **10.84** | **11.24** | <u>10.21</u> | 10.38 | **11.24** | 9.16 |
|
| 280 |
+
| **Playgroundv2.5** | 10.27 | 11.07 | 9.84 | <u>9.64</u> | 10.45 | <u>10.38</u> | 9.94 | 10.51 | <u>10.62</u> | 10.15 | <u>10.62</u> | 10.84 | 9.39 |
|
| 281 |
+
| **Infinity** | 10.26 | 11.17 | 9.95 | 9.43 | 10.36 | 9.27 | **10.11** | 10.36 | 10.59 | 10.08 | 10.30 | 10.59 | **9.62** |
|
| 282 |
+
| **CogView4** | 9.61 | 10.72 | 9.86 | 9.33 | 9.88 | 9.16 | 9.45 | 9.69 | 9.86 | 9.45 | 9.49 | 10.16 | 8.97 |
|
| 283 |
+
| **PixArt-Σ** | 9.37 | 10.08 | 9.07 | 8.41 | 9.83 | 8.86 | 8.87 | 9.44 | 9.57 | 9.52 | 9.73 | 10.35 | 8.58 |
|
| 284 |
+
| **Gemini 2.0 Flash** | 9.21 | 9.98 | 8.44 | 7.64 | 10.11 | 9.42 | 9.01 | 9.74 | 9.64 | 9.55 | 10.16 | 7.61 | 9.23 |
|
| 285 |
+
| **SDXL** | 8.20 | 8.67 | 7.63 | 7.53 | 8.57 | 8.18 | 7.76 | 8.65 | 8.85 | 8.32 | 8.43 | 8.78 | 7.29 |
|
| 286 |
+
| **HunyuanDiT** | 8.19 | 7.96 | 8.11 | 8.28 | 8.71 | 7.24 | 7.86 | 8.33 | 8.55 | 8.28 | 8.31 | 8.48 | 8.20 |
|
| 287 |
+
| **Stable Diffusion 3 Medium** | 5.31 | 6.70 | 5.98 | 5.15 | 5.25 | 4.09 | 5.24 | 4.25 | 5.71 | 5.84 | 6.01 | 5.71 | 4.58 |
|
| 288 |
+
| **SD2** | -0.24 | -0.34 | -0.56 | -1.35 | -0.24 | -0.54 | -0.32 | 1.00 | 1.11 | -0.01 | -0.38 | -0.38 | -0.84 |
|
| 289 |
+
|
| 290 |
+
</details>
|
| 291 |
+
|
| 292 |
---
|
| 293 |
|
| 294 |
+
## 🎯 CoHP (Chain-of-Human-Preference)
|
| 295 |
+
|
| 296 |
+
COHP is our novel reasoning approach for iterative image refinement that efficiently improves image quality without requiring additional training data. It works by generating images with multiple diffusion models, selecting the best one using reward models, and then iteratively refining it through image-to-image generation.
|
| 297 |
+
|
| 298 |
+
<p align="left">
|
| 299 |
+
<img src="assets/cohp.png" alt="cohp" width="600"/>
|
| 300 |
+
</p>
|
| 301 |
+
|
| 302 |
+
### 🚀 Usage
|
| 303 |
+
|
| 304 |
+
#### Basic Command
|
| 305 |
+
|
| 306 |
+
```bash
|
| 307 |
+
python hpsv3/cohp/run_cohp.py \
|
| 308 |
+
--prompt "A beautiful sunset over mountains" \
|
| 309 |
+
--index "sample_001" \
|
| 310 |
+
--device "cuda:0" \
|
| 311 |
+
--reward_model "hpsv3"
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
#### Parameters
|
| 315 |
+
|
| 316 |
+
- `--prompt`: Text prompt for image generation (required)
|
| 317 |
+
- `--index`: Unique identifier for saving results (required)
|
| 318 |
+
- `--device`: GPU device to use (default: 'cuda:1')
|
| 319 |
+
- `--reward_model`: Reward model for scoring images
|
| 320 |
+
- `hpsv3`: HPSv3 model (default, recommended)
|
| 321 |
+
- `hpsv2`: HPSv2 model
|
| 322 |
+
- `imagereward`: ImageReward model
|
| 323 |
+
- `pickscore`: PickScore model
|
| 324 |
+
|
| 325 |
+
#### Supported Generation Models
|
| 326 |
+
|
| 327 |
+
COHP uses multiple state-of-the-art diffusion models for initial generation: **FLUX.1 dev**, **Kolors**, **Stable Diffusion 3 Medium**, **Playground v2.5**
|
| 328 |
+
|
| 329 |
+
#### How COHP Works
|
| 330 |
+
|
| 331 |
+
1. **Multi-Model Generation**: Generates images using all supported models
|
| 332 |
+
2. **Reward Scoring**: Evaluates each image using the specified reward model
|
| 333 |
+
3. **Best Model Selection**: Chooses the model that achieves the highest average score for its generated images
|
| 334 |
+
4. **Iterative Refinement**: Performs 4 rounds of image-to-image generation to improve quality
|
| 335 |
+
5. **Adaptive Strength**: Uses strength=0.8 for rounds 1-2, then 0.5 for rounds 3-4
|
| 336 |
+
|
| 337 |
+
---
|
| 338 |
+
|
| 339 |
+
## 🦾 Results as Reward Model
|
| 340 |
+
|
| 341 |
+
We perform [DanceGRPO](https://github.com/XueZeyue/DanceGRPO) as the reinforcement learning method. Here are some results.
|
| 342 |
+
All experiments using the same setting and we use **Stable Diffusion 1.4** as our backbone.
|
| 343 |
+
|
| 344 |
+
<p align="left">
|
| 345 |
+
<img src="assets/rl1.jpg" width="600"/>
|
| 346 |
+
</p>
|
| 347 |
+
|
| 348 |
+
<p align="left">
|
| 349 |
+
<img src="assets/rl2.jpg" width="600"/>
|
| 350 |
+
</p>
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
### More Results of HPsv3 as Reward Model (Stable Diffusion 1.4)
|
| 354 |
+
<p align="left">
|
| 355 |
+
<img src="assets/rl_teaser.jpg" alt="cohp" width="600"/>
|
| 356 |
+
</p>
|
| 357 |
+
|
| 358 |
+
## 📚 Citation
|
| 359 |
+
|
| 360 |
+
If you find HPSv3 useful in your research, please cite our work:
|
| 361 |
+
|
| 362 |
+
```bibtex
|
| 363 |
+
@misc{ma2025hpsv3widespectrumhumanpreference,
|
| 364 |
+
title={HPSv3: Towards Wide-Spectrum Human Preference Score},
|
| 365 |
+
author={Yuhang Ma and Xiaoshi Wu and Keqiang Sun and Hongsheng Li},
|
| 366 |
+
year={2025},
|
| 367 |
+
eprint={2508.03789},
|
| 368 |
+
archivePrefix={arXiv},
|
| 369 |
+
primaryClass={cs.CV},
|
| 370 |
+
url={https://arxiv.org/abs/2508.03789},
|
| 371 |
+
}
|
| 372 |
+
```
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
---
|
| 376 |
+
|
| 377 |
+
## 🙏 Acknowledgements
|
| 378 |
+
|
| 379 |
+
We would like to thank the [VideoAlign](https://github.com/KwaiVGI/VideoAlign) codebase for providing valuable references.
|
| 380 |
+
|
| 381 |
+
---
|
| 382 |
+
|
| 383 |
+
## 💬 Support
|
| 384 |
+
|
| 385 |
+
For questions and support:
|
| 386 |
+
- **Issues**: [GitHub Issues](https://github.com/MizzenAI/HPSv3/issues)
|
| 387 |
+
- **Email**: yhshui@mizzen.ai & yhma@mizzen.ai
|
app.py
CHANGED
|
@@ -1,7 +1,525 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import torch
|
| 3 |
+
import os
|
| 4 |
+
import sys
|
| 5 |
+
from PIL import Image
|
| 6 |
+
import uuid
|
| 7 |
+
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
| 8 |
|
| 9 |
+
from hpsv3.inference import HPSv3RewardInferencer
|
| 10 |
+
try:
|
| 11 |
+
import ImageReward as RM
|
| 12 |
+
from hpsv2.src.open_clip import create_model_and_transforms, get_tokenizer
|
| 13 |
+
except:
|
| 14 |
+
RM = None
|
| 15 |
+
create_model_and_transforms = None
|
| 16 |
+
get_tokenizer = None
|
| 17 |
+
print("ImageReward or HPSv2 dependencies not found. Skipping those models.")
|
| 18 |
|
| 19 |
+
from transformers import AutoProcessor, AutoModel
|
| 20 |
+
|
| 21 |
+
# --- Configuration ---
|
| 22 |
+
DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 23 |
+
DTYPE = torch.bfloat16 if DEVICE == 'cuda' else torch.float32
|
| 24 |
+
|
| 25 |
+
# --- Model Configuration ---
|
| 26 |
+
MODEL_CONFIGS = {
|
| 27 |
+
"HPSv3_7B": {
|
| 28 |
+
"name": "HPSv3 7B",
|
| 29 |
+
"type": "hpsv3"
|
| 30 |
+
},
|
| 31 |
+
"HPSv2": {
|
| 32 |
+
"name": "HPSv2",
|
| 33 |
+
"checkpoint_path": "your_path_to_HPS_v2_compressed.pt",
|
| 34 |
+
"type": "hpsv2"
|
| 35 |
+
},
|
| 36 |
+
"ImageReward": {
|
| 37 |
+
"name": "ImageReward v1.0",
|
| 38 |
+
"checkpoint_path": "ImageReward-v1.0",
|
| 39 |
+
"type": "imagereward"
|
| 40 |
+
},
|
| 41 |
+
"PickScore": {
|
| 42 |
+
"name": "PickScore",
|
| 43 |
+
"checkpoint_path": "your_path_to_pickscore",
|
| 44 |
+
"type": "pickscore"
|
| 45 |
+
},
|
| 46 |
+
"CLIP": {
|
| 47 |
+
"name": "CLIP ViT-H-14",
|
| 48 |
+
"checkpoint_path": "/preflab/models/CLIP-ViT-H-14-laion2B-s32B-b79K",
|
| 49 |
+
"type": "clip"
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# --- Global Model Storage ---
|
| 54 |
+
current_models = {}
|
| 55 |
+
current_model_name = None
|
| 56 |
+
|
| 57 |
+
# --- Dynamic Model Loading Functions ---
|
| 58 |
+
def load_model(model_key, update_status_fn=None):
|
| 59 |
+
"""Load the specified model based on the model key."""
|
| 60 |
+
global current_models, current_model_name
|
| 61 |
+
|
| 62 |
+
if model_key == current_model_name and model_key in current_models:
|
| 63 |
+
return current_models[model_key]
|
| 64 |
+
|
| 65 |
+
if update_status_fn:
|
| 66 |
+
update_status_fn(f"🔄 Loading {MODEL_CONFIGS[model_key]['name']}...")
|
| 67 |
+
|
| 68 |
+
# Clear previous models to save memory
|
| 69 |
+
current_models.clear()
|
| 70 |
+
torch.cuda.empty_cache()
|
| 71 |
+
|
| 72 |
+
config = MODEL_CONFIGS[model_key]
|
| 73 |
+
|
| 74 |
+
try:
|
| 75 |
+
if config["type"] == "hpsv3":
|
| 76 |
+
model = HPSv3RewardInferencer(
|
| 77 |
+
device=DEVICE,
|
| 78 |
+
)
|
| 79 |
+
elif config["type"] == "hpsv2":
|
| 80 |
+
model_obj, preprocess_train, preprocess_val = create_model_and_transforms(
|
| 81 |
+
'ViT-H-14',
|
| 82 |
+
'laion2B-s32B-b79K',
|
| 83 |
+
precision='amp',
|
| 84 |
+
device=DEVICE,
|
| 85 |
+
jit=False,
|
| 86 |
+
force_quick_gelu=False,
|
| 87 |
+
force_custom_text=False,
|
| 88 |
+
force_patch_dropout=False,
|
| 89 |
+
force_image_size=None,
|
| 90 |
+
pretrained_image=False,
|
| 91 |
+
image_mean=None,
|
| 92 |
+
image_std=None,
|
| 93 |
+
light_augmentation=True,
|
| 94 |
+
aug_cfg={},
|
| 95 |
+
output_dict=True,
|
| 96 |
+
with_score_predictor=False,
|
| 97 |
+
with_region_predictor=False
|
| 98 |
+
)
|
| 99 |
+
checkpoint = torch.load(config["checkpoint_path"], map_location=DEVICE, weights_only=False)
|
| 100 |
+
model_obj.load_state_dict(checkpoint['state_dict'])
|
| 101 |
+
model_obj = model_obj.to(DEVICE).eval()
|
| 102 |
+
tokenizer = get_tokenizer('ViT-H-14')
|
| 103 |
+
model = {"model": model_obj, "preprocess_val": preprocess_val, "tokenizer": tokenizer}
|
| 104 |
+
elif config["type"] == "imagereward":
|
| 105 |
+
model = RM.load(config["checkpoint_path"])
|
| 106 |
+
elif config["type"] == "pickscore":
|
| 107 |
+
processor = AutoProcessor.from_pretrained('/preflab/models/CLIP-ViT-H-14-laion2B-s32B-b79K')
|
| 108 |
+
model_obj = AutoModel.from_pretrained(config["checkpoint_path"]).eval().to(DEVICE)
|
| 109 |
+
model = {"model": model_obj, "processor": processor}
|
| 110 |
+
elif config["type"] == "clip":
|
| 111 |
+
model_obj = AutoModel.from_pretrained(config["checkpoint_path"]).to(DEVICE)
|
| 112 |
+
processor = AutoProcessor.from_pretrained(config["checkpoint_path"])
|
| 113 |
+
model = {"model": model_obj, "processor": processor}
|
| 114 |
+
else:
|
| 115 |
+
raise ValueError(f"Unknown model type: {config['type']}")
|
| 116 |
+
|
| 117 |
+
current_models[model_key] = model
|
| 118 |
+
current_model_name = model_key
|
| 119 |
+
|
| 120 |
+
if update_status_fn:
|
| 121 |
+
update_status_fn(f"✅ {MODEL_CONFIGS[model_key]['name']} loaded successfully!")
|
| 122 |
+
|
| 123 |
+
return model
|
| 124 |
+
except Exception as e:
|
| 125 |
+
error_msg = f"Error loading model {model_key}: {e}"
|
| 126 |
+
print(error_msg)
|
| 127 |
+
if update_status_fn:
|
| 128 |
+
update_status_fn(f"❌ {error_msg}")
|
| 129 |
+
return None
|
| 130 |
+
|
| 131 |
+
def score_with_model(model_key, image_paths, prompts):
|
| 132 |
+
"""Score images using the specified model."""
|
| 133 |
+
model = load_model(model_key)
|
| 134 |
+
if model is None:
|
| 135 |
+
raise ValueError(f"Failed to load model {model_key}")
|
| 136 |
+
|
| 137 |
+
config = MODEL_CONFIGS[model_key]
|
| 138 |
+
|
| 139 |
+
if config["type"] == "hpsv3":
|
| 140 |
+
rewards = model.reward(image_paths, prompts)
|
| 141 |
+
return [reward[0].item() for reward in rewards] # HPSv3 returns tensor with multiple values, take first
|
| 142 |
+
elif config["type"] == "hpsv2":
|
| 143 |
+
return score_hpsv2_batch(model, image_paths, prompts)
|
| 144 |
+
elif config["type"] == "imagereward":
|
| 145 |
+
return [model.score(prompt, image_path) for prompt, image_path in zip(prompts, image_paths)]
|
| 146 |
+
elif config["type"] == "pickscore":
|
| 147 |
+
return score_pickscore_batch(prompts, image_paths, model["model"], model["processor"])
|
| 148 |
+
elif config["type"] == "clip":
|
| 149 |
+
return score_clip_batch(model["model"], model["processor"], image_paths, prompts)
|
| 150 |
+
else:
|
| 151 |
+
raise ValueError(f"Unknown model type: {config['type']}")
|
| 152 |
+
|
| 153 |
+
def score_hpsv2_batch(model_dict, image_paths, prompts):
|
| 154 |
+
"""Score using HPSv2 model."""
|
| 155 |
+
model = model_dict['model']
|
| 156 |
+
preprocess_val = model_dict['preprocess_val']
|
| 157 |
+
tokenizer = model_dict['tokenizer']
|
| 158 |
+
|
| 159 |
+
# 批量处理图片
|
| 160 |
+
images = [preprocess_val(Image.open(p)).unsqueeze(0)[:,:3,:,:] for p in image_paths]
|
| 161 |
+
images = torch.cat(images, dim=0).to(device=DEVICE)
|
| 162 |
+
texts = tokenizer(prompts).to(device=DEVICE)
|
| 163 |
+
with torch.no_grad():
|
| 164 |
+
outputs = model(images, texts)
|
| 165 |
+
image_features, text_features = outputs["image_features"], outputs["text_features"]
|
| 166 |
+
logits_per_image = image_features @ text_features.T
|
| 167 |
+
hps_scores = torch.diagonal(logits_per_image).cpu()
|
| 168 |
+
return [score.item() for score in hps_scores]
|
| 169 |
+
|
| 170 |
+
def score_pickscore_batch(prompts, image_paths, model, processor):
|
| 171 |
+
"""Score using PickScore model."""
|
| 172 |
+
pil_images = [Image.open(p) for p in image_paths]
|
| 173 |
+
image_inputs = processor(
|
| 174 |
+
images=pil_images,
|
| 175 |
+
padding=True,
|
| 176 |
+
truncation=True,
|
| 177 |
+
max_length=77,
|
| 178 |
+
return_tensors="pt",
|
| 179 |
+
).to(DEVICE)
|
| 180 |
+
|
| 181 |
+
text_inputs = processor(
|
| 182 |
+
text=prompts,
|
| 183 |
+
padding=True,
|
| 184 |
+
truncation=True,
|
| 185 |
+
max_length=77,
|
| 186 |
+
return_tensors="pt",
|
| 187 |
+
).to(DEVICE)
|
| 188 |
+
|
| 189 |
+
with torch.no_grad():
|
| 190 |
+
image_embs = model.get_image_features(**image_inputs)
|
| 191 |
+
image_embs = image_embs / torch.norm(image_embs, dim=-1, keepdim=True)
|
| 192 |
+
text_embs = model.get_text_features(**text_inputs)
|
| 193 |
+
text_embs = text_embs / torch.norm(text_embs, dim=-1, keepdim=True)
|
| 194 |
+
scores = model.logit_scale.exp() * (text_embs @ image_embs.T)
|
| 195 |
+
return [scores[i, i].cpu().item() for i in range(len(prompts))]
|
| 196 |
+
|
| 197 |
+
def score_clip_batch(model, processor, image_paths, prompts):
|
| 198 |
+
"""Score using CLIP model."""
|
| 199 |
+
pil_images = [Image.open(p) for p in image_paths]
|
| 200 |
+
image_inputs = processor(
|
| 201 |
+
images=pil_images,
|
| 202 |
+
padding=True,
|
| 203 |
+
truncation=True,
|
| 204 |
+
max_length=77,
|
| 205 |
+
return_tensors="pt",
|
| 206 |
+
).to(DEVICE)
|
| 207 |
+
|
| 208 |
+
text_inputs = processor(
|
| 209 |
+
text=prompts,
|
| 210 |
+
padding=True,
|
| 211 |
+
truncation=True,
|
| 212 |
+
max_length=77,
|
| 213 |
+
return_tensors="pt",
|
| 214 |
+
).to(DEVICE)
|
| 215 |
+
|
| 216 |
+
with torch.no_grad():
|
| 217 |
+
image_embs = model.get_image_features(**image_inputs)
|
| 218 |
+
image_embs = image_embs / torch.norm(image_embs, dim=-1, keepdim=True)
|
| 219 |
+
text_embs = model.get_text_features(**text_inputs)
|
| 220 |
+
text_embs = text_embs / torch.norm(text_embs, dim=-1, keepdim=True)
|
| 221 |
+
scores = image_embs @ text_embs.T
|
| 222 |
+
return [scores[i, i].cpu().item() for i in range(len(prompts))]
|
| 223 |
+
|
| 224 |
+
# Load default model
|
| 225 |
+
print("Loading default HPSv3 model...")
|
| 226 |
+
load_model("HPSv3_7B")
|
| 227 |
+
print("Model loaded successfully.")
|
| 228 |
+
|
| 229 |
+
# --- Helper Functions ---
|
| 230 |
+
def get_score_interpretation(score):
|
| 231 |
+
"""Returns a color-coded qualitative interpretation of the score."""
|
| 232 |
+
if score is None:
|
| 233 |
+
return ""
|
| 234 |
+
|
| 235 |
+
if score < 0:
|
| 236 |
+
color = "#ef4444" # Modern red
|
| 237 |
+
bg_color = "rgba(239, 68, 68, 0.1)"
|
| 238 |
+
icon = "❌"
|
| 239 |
+
feedback = "Poor Quality"
|
| 240 |
+
comment = "The image has significant quality issues or doesn't match the prompt well."
|
| 241 |
+
elif score < 5:
|
| 242 |
+
color = "#f59e0b" # Modern amber
|
| 243 |
+
bg_color = "rgba(245, 158, 11, 0.1)"
|
| 244 |
+
icon = "⚠️"
|
| 245 |
+
feedback = "Needs Improvement"
|
| 246 |
+
comment = "The image is acceptable but could be enhanced in quality or prompt alignment."
|
| 247 |
+
elif score < 10:
|
| 248 |
+
color = "#10b981" # Modern emerald
|
| 249 |
+
bg_color = "rgba(16, 185, 129, 0.1)"
|
| 250 |
+
icon = "✅"
|
| 251 |
+
feedback = "Good Quality"
|
| 252 |
+
comment = "A well-crafted image that aligns nicely with the given prompt."
|
| 253 |
+
else: # score >= 10
|
| 254 |
+
color = "#06d6a0" # Vibrant teal
|
| 255 |
+
bg_color = "rgba(6, 214, 160, 0.1)"
|
| 256 |
+
icon = "⭐"
|
| 257 |
+
feedback = "Excellent!"
|
| 258 |
+
comment = "Outstanding quality and perfect alignment with the prompt."
|
| 259 |
+
|
| 260 |
+
return f"""
|
| 261 |
+
<div style='
|
| 262 |
+
background: {bg_color};
|
| 263 |
+
border: 2px solid {color};
|
| 264 |
+
border-radius: 16px;
|
| 265 |
+
padding: 20px;
|
| 266 |
+
text-align: center;
|
| 267 |
+
margin: 10px 0;
|
| 268 |
+
'>
|
| 269 |
+
<div style='font-size: 2rem; margin-bottom: 8px;'>{icon}</div>
|
| 270 |
+
<h3 style='color: {color}; font-size: 1.4rem; font-weight: 700; margin: 8px 0;'>{feedback}</h3>
|
| 271 |
+
<p style='color: #666; font-size: 0.95rem; margin: 0; line-height: 1.4;'>{comment}</p>
|
| 272 |
+
</div>
|
| 273 |
+
"""
|
| 274 |
+
|
| 275 |
+
# --- Model Change Handler ---
|
| 276 |
+
def handle_model_change(model_key):
|
| 277 |
+
"""Handle model selection change."""
|
| 278 |
+
global current_model_name
|
| 279 |
+
|
| 280 |
+
if model_key != current_model_name:
|
| 281 |
+
# Show loading status
|
| 282 |
+
yield f"🔄 Loading {MODEL_CONFIGS[model_key]['name']}..."
|
| 283 |
+
|
| 284 |
+
# Load the new model
|
| 285 |
+
model = load_model(model_key)
|
| 286 |
+
|
| 287 |
+
if model is not None:
|
| 288 |
+
yield f"✅ Current model: {MODEL_CONFIGS[model_key]['name']}"
|
| 289 |
+
else:
|
| 290 |
+
yield f"❌ Failed to load {MODEL_CONFIGS[model_key]['name']}"
|
| 291 |
+
else:
|
| 292 |
+
yield f"✅ Current model: {MODEL_CONFIGS[model_key]['name']}"
|
| 293 |
+
|
| 294 |
+
# --- Prediction Function ---
|
| 295 |
+
def predict_score(image, prompt, model_name):
|
| 296 |
+
"""Takes Gradio inputs and returns the score, interpretation, and status."""
|
| 297 |
+
if image is None:
|
| 298 |
+
return None, "", "❌ Error: Please upload an image."
|
| 299 |
+
if not prompt or not prompt.strip():
|
| 300 |
+
return None, "", "❌ Error: Please enter a prompt."
|
| 301 |
+
|
| 302 |
+
temp_dir = "temp_images_for_gradio"
|
| 303 |
+
os.makedirs(temp_dir, exist_ok=True)
|
| 304 |
+
temp_path = os.path.join(temp_dir, f"{uuid.uuid4()}.png")
|
| 305 |
+
|
| 306 |
+
try:
|
| 307 |
+
Image.fromarray(image).save(temp_path)
|
| 308 |
+
scores = score_with_model(model_name, [temp_path], [prompt])
|
| 309 |
+
score = round(scores[0], 4)
|
| 310 |
+
interpretation = get_score_interpretation(score)
|
| 311 |
+
return score, interpretation, "✅ Analysis completed successfully!"
|
| 312 |
+
except Exception as e:
|
| 313 |
+
print(f"An error occurred during inference: {e}")
|
| 314 |
+
return None, "", f"❌ Processing error: {e}"
|
| 315 |
+
finally:
|
| 316 |
+
if os.path.exists(temp_path):
|
| 317 |
+
os.remove(temp_path)
|
| 318 |
+
|
| 319 |
+
# --- Image Comparison Function ---
|
| 320 |
+
def compare_images(image1, image2, prompt, model_name):
|
| 321 |
+
"""Compare two images and determine which one is better based on the prompt."""
|
| 322 |
+
if image1 is None or image2 is None:
|
| 323 |
+
return None, None, "", "❌ Error: Please upload both images."
|
| 324 |
+
if not prompt or not prompt.strip():
|
| 325 |
+
return None, None, "", "❌ Error: Please enter a prompt."
|
| 326 |
+
|
| 327 |
+
temp_dir = "temp_images_for_gradio"
|
| 328 |
+
os.makedirs(temp_dir, exist_ok=True)
|
| 329 |
+
temp_path1 = os.path.join(temp_dir, f"{uuid.uuid4()}_img1.png")
|
| 330 |
+
temp_path2 = os.path.join(temp_dir, f"{uuid.uuid4()}_img2.png")
|
| 331 |
+
|
| 332 |
+
try:
|
| 333 |
+
Image.fromarray(image1).save(temp_path1)
|
| 334 |
+
Image.fromarray(image2).save(temp_path2)
|
| 335 |
+
|
| 336 |
+
# Get scores for both images
|
| 337 |
+
scores = score_with_model(model_name, [temp_path1, temp_path2], [prompt, prompt])
|
| 338 |
+
score1 = round(scores[0], 4)
|
| 339 |
+
score2 = round(scores[1], 4)
|
| 340 |
+
|
| 341 |
+
# Determine winner
|
| 342 |
+
if score1 > score2:
|
| 343 |
+
winner_text = f"🏆 **Image 1 is better!**\n\nImage 1 Score: **{score1}**\nImage 2 Score: **{score2}**\n\nDifference: **+{round(score1-score2, 4)}**"
|
| 344 |
+
elif score2 > score1:
|
| 345 |
+
winner_text = f"🏆 **Image 2 is better!**\n\nImage 1 Score: **{score1}**\nImage 2 Score: **{score2}**\n\nDifference: **+{round(score2-score1, 4)}**"
|
| 346 |
+
else:
|
| 347 |
+
winner_text = f"🤝 **It's a tie!**\n\nBoth images scored: **{score1}**"
|
| 348 |
+
|
| 349 |
+
return score1, score2, winner_text, "✅ Comparison completed successfully!"
|
| 350 |
+
|
| 351 |
+
except Exception as e:
|
| 352 |
+
print(f"An error occurred during comparison: {e}")
|
| 353 |
+
return None, None, "", f"❌ Processing error: {e}"
|
| 354 |
+
finally:
|
| 355 |
+
if os.path.exists(temp_path1):
|
| 356 |
+
os.remove(temp_path1)
|
| 357 |
+
if os.path.exists(temp_path2):
|
| 358 |
+
os.remove(temp_path2)
|
| 359 |
+
|
| 360 |
+
# --- Gradio Interface ---
|
| 361 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="HPSv3 - Human Preference Score v3") as demo:
|
| 362 |
+
gr.HTML(f"""
|
| 363 |
+
<div style="text-align: center; margin-bottom: 20px;">
|
| 364 |
+
<h1>🎨 HPSv3: Human Preference Score v3</h1>
|
| 365 |
+
<p>Evaluate image quality and alignment with prompts with multiple models.</p>
|
| 366 |
+
<p><a href="https://mizzenai.github.io/HPSv3.project/" target="_blank">🌐 Project Website</a> |
|
| 367 |
+
<a href="https://huggingface.co/papers/2508.03789" target="_blank">📄 Paper</a> |
|
| 368 |
+
<a href="https://github.com/MizzenAI/HPSv3" target="_blank">💻 Code</a></p>
|
| 369 |
+
</div>
|
| 370 |
+
""")
|
| 371 |
+
|
| 372 |
+
# Global model selector
|
| 373 |
+
with gr.Row():
|
| 374 |
+
model_selector = gr.Dropdown(
|
| 375 |
+
choices=[(config["name"], key) for key, config in MODEL_CONFIGS.items()],
|
| 376 |
+
value="HPSv3_7B",
|
| 377 |
+
label="🤖 Select Model",
|
| 378 |
+
)
|
| 379 |
+
model_status = gr.Textbox(
|
| 380 |
+
label="Model Status",
|
| 381 |
+
value=f"✅ Current model: {MODEL_CONFIGS['HPSv3_7B']['name']}",
|
| 382 |
+
interactive=False,
|
| 383 |
+
scale=2
|
| 384 |
+
)
|
| 385 |
+
|
| 386 |
+
with gr.Tabs():
|
| 387 |
+
# Tab 1: Single Image Scoring
|
| 388 |
+
with gr.TabItem("📊 Image Scoring"):
|
| 389 |
+
with gr.Row(equal_height=False):
|
| 390 |
+
with gr.Column(scale=2):
|
| 391 |
+
with gr.Group():
|
| 392 |
+
gr.Markdown("### 🖼️ **Upload & Describe**")
|
| 393 |
+
image_input = gr.Image(
|
| 394 |
+
type="numpy",
|
| 395 |
+
label="Upload Image",
|
| 396 |
+
height=450
|
| 397 |
+
)
|
| 398 |
+
prompt_input = gr.Textbox(
|
| 399 |
+
label="Prompt Description",
|
| 400 |
+
placeholder="Describe what the image should represent...",
|
| 401 |
+
lines=3,
|
| 402 |
+
max_lines=5
|
| 403 |
+
)
|
| 404 |
+
|
| 405 |
+
with gr.Column(scale=1):
|
| 406 |
+
with gr.Group():
|
| 407 |
+
gr.Markdown("### 🎯 **Quality Assessment**")
|
| 408 |
+
score_output = gr.Number(
|
| 409 |
+
label="Score",
|
| 410 |
+
elem_id="score-output",
|
| 411 |
+
precision=4
|
| 412 |
+
)
|
| 413 |
+
interpretation_output = gr.Markdown(label="")
|
| 414 |
+
status_output = gr.Textbox(
|
| 415 |
+
label="Status",
|
| 416 |
+
interactive=False
|
| 417 |
+
)
|
| 418 |
+
submit_button = gr.Button(
|
| 419 |
+
"🚀 Run Evaluation",
|
| 420 |
+
variant="primary",
|
| 421 |
+
size="lg"
|
| 422 |
+
)
|
| 423 |
+
|
| 424 |
+
submit_button.click(
|
| 425 |
+
fn=predict_score,
|
| 426 |
+
inputs=[image_input, prompt_input, model_selector],
|
| 427 |
+
outputs=[score_output, interpretation_output, status_output]
|
| 428 |
+
)
|
| 429 |
+
|
| 430 |
+
with gr.Group():
|
| 431 |
+
gr.Examples(
|
| 432 |
+
examples=[
|
| 433 |
+
["assets/example1.png", "cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker, high resolution, vibrant colors"],
|
| 434 |
+
["assets/example2.png", "cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker, high resolution, vibrant colors"],
|
| 435 |
+
],
|
| 436 |
+
inputs=[image_input, prompt_input],
|
| 437 |
+
outputs=[score_output, interpretation_output, status_output],
|
| 438 |
+
fn=lambda img, prompt: predict_score(img, prompt, "HPSv3_7B"),
|
| 439 |
+
cache_examples=False
|
| 440 |
+
)
|
| 441 |
+
|
| 442 |
+
# Tab 2: Image Comparison
|
| 443 |
+
with gr.TabItem("⚖️ Image Comparison"):
|
| 444 |
+
with gr.Row(equal_height=False):
|
| 445 |
+
with gr.Column(scale=2):
|
| 446 |
+
with gr.Group():
|
| 447 |
+
gr.Markdown("### 🖼️ **Upload Images & Prompt**")
|
| 448 |
+
with gr.Row():
|
| 449 |
+
image1_input = gr.Image(
|
| 450 |
+
type="numpy",
|
| 451 |
+
label="Image 1",
|
| 452 |
+
height=300
|
| 453 |
+
)
|
| 454 |
+
image2_input = gr.Image(
|
| 455 |
+
type="numpy",
|
| 456 |
+
label="Image 2",
|
| 457 |
+
height=300
|
| 458 |
+
)
|
| 459 |
+
prompt_compare_input = gr.Textbox(
|
| 460 |
+
label="Prompt Description",
|
| 461 |
+
placeholder="Describe what the images should represent...",
|
| 462 |
+
lines=3,
|
| 463 |
+
max_lines=5
|
| 464 |
+
)
|
| 465 |
+
|
| 466 |
+
with gr.Column(scale=1):
|
| 467 |
+
with gr.Group():
|
| 468 |
+
gr.Markdown("### 🎯 **Comparison Results**")
|
| 469 |
+
score1_output = gr.Number(
|
| 470 |
+
label="Image 1 Score",
|
| 471 |
+
precision=4
|
| 472 |
+
)
|
| 473 |
+
score2_output = gr.Number(
|
| 474 |
+
label="Image 2 Score",
|
| 475 |
+
precision=4
|
| 476 |
+
)
|
| 477 |
+
comparison_result = gr.Markdown(label="Winner")
|
| 478 |
+
status_compare_output = gr.Textbox(
|
| 479 |
+
label="Status",
|
| 480 |
+
interactive=False
|
| 481 |
+
)
|
| 482 |
+
|
| 483 |
+
compare_button = gr.Button(
|
| 484 |
+
"⚖️ Compare Images",
|
| 485 |
+
variant="primary",
|
| 486 |
+
size="lg"
|
| 487 |
+
)
|
| 488 |
+
|
| 489 |
+
compare_button.click(
|
| 490 |
+
fn=compare_images,
|
| 491 |
+
inputs=[image1_input, image2_input, prompt_compare_input, model_selector],
|
| 492 |
+
outputs=[score1_output, score2_output, comparison_result, status_compare_output]
|
| 493 |
+
)
|
| 494 |
+
|
| 495 |
+
with gr.Group():
|
| 496 |
+
gr.Examples(
|
| 497 |
+
examples=[
|
| 498 |
+
["assets/example1.png", "assets/example2.png", "cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker, high resolution, vibrant colors"],
|
| 499 |
+
["assets/example2.png", "assets/example1.png", "cute chibi anime cartoon fox, smiling wagging tail with a small cartoon heart above sticker, high resolution, vibrant colors"],
|
| 500 |
+
],
|
| 501 |
+
inputs=[image1_input, image2_input, prompt_compare_input],
|
| 502 |
+
outputs=[score1_output, score2_output, comparison_result, status_compare_output],
|
| 503 |
+
fn=lambda img1, img2, prompt: compare_images(img1, img2, prompt, "HPSv3_7B"),
|
| 504 |
+
cache_examples=False
|
| 505 |
+
)
|
| 506 |
+
|
| 507 |
+
# Model change handler
|
| 508 |
+
model_selector.change(
|
| 509 |
+
fn=handle_model_change,
|
| 510 |
+
inputs=[model_selector],
|
| 511 |
+
outputs=[model_status]
|
| 512 |
+
)
|
| 513 |
+
|
| 514 |
+
def main():
|
| 515 |
+
"""Main function to launch the demo."""
|
| 516 |
+
demo.launch(
|
| 517 |
+
server_name="0.0.0.0",
|
| 518 |
+
server_port=7860,
|
| 519 |
+
share=False,
|
| 520 |
+
favicon_path=None,
|
| 521 |
+
show_error=True,
|
| 522 |
+
)
|
| 523 |
+
|
| 524 |
+
if __name__ == "__main__":
|
| 525 |
+
main()
|
requirements.txt
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 5 |
+
aiosignal==1.3.2
|
| 6 |
+
annotated-types==0.7.0
|
| 7 |
+
antlr4-python3-runtime==4.9.3
|
| 8 |
+
anyio==4.9.0
|
| 9 |
+
argon2-cffi==23.1.0
|
| 10 |
+
argon2-cffi-bindings==21.2.0
|
| 11 |
+
arrow==1.3.0
|
| 12 |
+
asttokens==3.0.0
|
| 13 |
+
async-lru==2.0.5
|
| 14 |
+
async-timeout==5.0.1
|
| 15 |
+
attrs==25.3.0
|
| 16 |
+
av==14.4.0
|
| 17 |
+
babel==2.17.0
|
| 18 |
+
beautifulsoup4==4.13.4
|
| 19 |
+
bleach==6.2.0
|
| 20 |
+
botocore==1.38.35
|
| 21 |
+
certifi==2025.4.26
|
| 22 |
+
cffi==1.17.1
|
| 23 |
+
charset-normalizer==3.4.2
|
| 24 |
+
comm==0.2.2
|
| 25 |
+
contourpy==1.3.2
|
| 26 |
+
cycler==0.12.1
|
| 27 |
+
datasets==3.6.0
|
| 28 |
+
debugpy==1.8.14
|
| 29 |
+
decorator==5.2.1
|
| 30 |
+
deepspeed==0.15.4
|
| 31 |
+
defusedxml==0.7.1
|
| 32 |
+
diffusers==0.33.1
|
| 33 |
+
dill==0.3.8
|
| 34 |
+
docstring-parser==0.16
|
| 35 |
+
einops==0.8.1
|
| 36 |
+
exceptiongroup==1.3.0
|
| 37 |
+
executing==2.2.0
|
| 38 |
+
fastjsonschema==2.21.1
|
| 39 |
+
filelock==3.13.1
|
| 40 |
+
fire==0.7.0
|
| 41 |
+
fonttools==4.58.1
|
| 42 |
+
fqdn==1.5.1
|
| 43 |
+
frozenlist==1.7.0
|
| 44 |
+
fsspec==2024.6.1
|
| 45 |
+
grpcio==1.72.1
|
| 46 |
+
h11==0.16.0
|
| 47 |
+
hf-xet==1.1.3
|
| 48 |
+
hjson==3.1.0
|
| 49 |
+
httpcore==1.0.9
|
| 50 |
+
httpx==0.28.1
|
| 51 |
+
huggingface-hub==0.32.4
|
| 52 |
+
idna==3.10
|
| 53 |
+
imageio==2.37.0
|
| 54 |
+
importlib-metadata==8.7.0
|
| 55 |
+
ipykernel==6.29.5
|
| 56 |
+
ipython==8.36.0
|
| 57 |
+
ipywidgets==8.1.7
|
| 58 |
+
isoduration==20.11.0
|
| 59 |
+
jedi==0.19.2
|
| 60 |
+
jinja2==3.1.6
|
| 61 |
+
jmespath==1.0.1
|
| 62 |
+
json5==0.12.0
|
| 63 |
+
jsonpointer==3.0.0
|
| 64 |
+
jsonschema==4.24.0
|
| 65 |
+
jsonschema-specifications==2025.4.1
|
| 66 |
+
jupyter==1.1.1
|
| 67 |
+
jupyter-client==8.6.3
|
| 68 |
+
jupyter-console==6.6.3
|
| 69 |
+
jupyter-core==5.8.1
|
| 70 |
+
jupyter-events==0.12.0
|
| 71 |
+
jupyter-lsp==2.2.5
|
| 72 |
+
jupyter-server==2.16.0
|
| 73 |
+
jupyter-server-terminals==0.5.3
|
| 74 |
+
jupyterlab==4.4.3
|
| 75 |
+
jupyterlab-pygments==0.3.0
|
| 76 |
+
jupyterlab-server==2.27.3
|
| 77 |
+
jupyterlab-widgets==3.0.15
|
| 78 |
+
kiwisolver==1.4.8
|
| 79 |
+
markdown==3.8
|
| 80 |
+
markdown-it-py==3.0.0
|
| 81 |
+
markupsafe==3.0.2
|
| 82 |
+
matplotlib==3.10.3
|
| 83 |
+
matplotlib-inline==0.1.7
|
| 84 |
+
mdurl==0.1.2
|
| 85 |
+
mistune==3.1.3
|
| 86 |
+
mpmath==1.3.0
|
| 87 |
+
msgpack==1.1.0
|
| 88 |
+
multidict==6.4.4
|
| 89 |
+
multiprocess==0.70.16
|
| 90 |
+
nbclient==0.10.2
|
| 91 |
+
nbconvert==7.16.6
|
| 92 |
+
nbformat==5.10.4
|
| 93 |
+
nest-asyncio==1.6.0
|
| 94 |
+
networkx==3.3
|
| 95 |
+
ninja==1.11.1.4
|
| 96 |
+
notebook==7.4.3
|
| 97 |
+
notebook-shim==0.2.4
|
| 98 |
+
numpy==2.1.2
|
| 99 |
+
nvidia-cublas-cu11==11.11.3.6
|
| 100 |
+
nvidia-cuda-cupti-cu11==11.8.87
|
| 101 |
+
nvidia-cuda-nvrtc-cu11==11.8.89
|
| 102 |
+
nvidia-cuda-runtime-cu11==11.8.89
|
| 103 |
+
nvidia-cudnn-cu11==9.1.0.70
|
| 104 |
+
nvidia-cufft-cu11==10.9.0.58
|
| 105 |
+
nvidia-curand-cu11==10.3.0.86
|
| 106 |
+
nvidia-cusolver-cu11==11.4.1.48
|
| 107 |
+
nvidia-cusparse-cu11==11.7.5.86
|
| 108 |
+
nvidia-ml-py==12.575.51
|
| 109 |
+
nvidia-nccl-cu11==2.21.5
|
| 110 |
+
nvidia-nvtx-cu11==11.8.86
|
| 111 |
+
omegaconf==2.3.0
|
| 112 |
+
opencv-python==4.11.0.86
|
| 113 |
+
overrides==7.7.0
|
| 114 |
+
packaging==25.0
|
| 115 |
+
pandas==2.3.0
|
| 116 |
+
pandocfilters==1.5.1
|
| 117 |
+
parso==0.8.4
|
| 118 |
+
peft==0.10.0
|
| 119 |
+
pexpect==4.9.0
|
| 120 |
+
pillow==11.0.0
|
| 121 |
+
platformdirs==4.3.8
|
| 122 |
+
prometheus-client==0.22.0
|
| 123 |
+
prompt-toolkit==3.0.51
|
| 124 |
+
propcache==0.3.2
|
| 125 |
+
protobuf==6.31.1
|
| 126 |
+
psutil==7.0.0
|
| 127 |
+
ptyprocess==0.7.0
|
| 128 |
+
pure-eval==0.2.3
|
| 129 |
+
py-cpuinfo==9.0.0
|
| 130 |
+
pyarrow==20.0.0
|
| 131 |
+
pycparser==2.22
|
| 132 |
+
pydantic==2.11.5
|
| 133 |
+
pydantic-core==2.33.2
|
| 134 |
+
pygments==2.19.1
|
| 135 |
+
pyparsing==3.2.3
|
| 136 |
+
python-dateutil==2.9.0.post0
|
| 137 |
+
python-json-logger==3.3.0
|
| 138 |
+
pytz==2025.2
|
| 139 |
+
pyyaml==6.0.2
|
| 140 |
+
pyzmq==26.4.0
|
| 141 |
+
prettytable==3.8.0
|
| 142 |
+
qwen-vl-utils==0.0.11
|
| 143 |
+
referencing==0.36.2
|
| 144 |
+
regex==2024.11.6
|
| 145 |
+
requests==2.32.3
|
| 146 |
+
rfc3339-validator==0.1.4
|
| 147 |
+
rfc3986-validator==0.1.1
|
| 148 |
+
rich==14.0.0
|
| 149 |
+
rpds-py==0.25.1
|
| 150 |
+
safetensors==0.5.3
|
| 151 |
+
send2trash==1.8.3
|
| 152 |
+
sentencepiece==0.2.0
|
| 153 |
+
shtab==1.7.2
|
| 154 |
+
six==1.17.0
|
| 155 |
+
sniffio==1.3.1
|
| 156 |
+
soupsieve==2.7
|
| 157 |
+
stack-data==0.6.3
|
| 158 |
+
sympy==1.13.1
|
| 159 |
+
tensorboard==2.19.0
|
| 160 |
+
tensorboard-data-server==0.7.2
|
| 161 |
+
termcolor==3.1.0
|
| 162 |
+
terminado==0.18.1
|
| 163 |
+
timm==1.0.15
|
| 164 |
+
tinycss2==1.4.0
|
| 165 |
+
tokenizers==0.20.3
|
| 166 |
+
tomli==2.2.1
|
| 167 |
+
torch==2.6.0
|
| 168 |
+
torchaudio==2.6.0
|
| 169 |
+
torchvision==0.21.0
|
| 170 |
+
tornado==6.5.1
|
| 171 |
+
tqdm==4.67.1
|
| 172 |
+
traitlets==5.14.3
|
| 173 |
+
transformers==4.45.2
|
| 174 |
+
triton==3.2.0
|
| 175 |
+
trl==0.8.6
|
| 176 |
+
typeguard==4.4.3
|
| 177 |
+
types-python-dateutil==2.9.0.20250516
|
| 178 |
+
typing-extensions==4.14.0
|
| 179 |
+
typing-inspection==0.4.1
|
| 180 |
+
tyro==0.9.24
|
| 181 |
+
tzdata==2025.2
|
| 182 |
+
uri-template==1.3.0
|
| 183 |
+
urllib3==2.4.0
|
| 184 |
+
wcwidth==0.2.13
|
| 185 |
+
webcolors==24.11.1
|
| 186 |
+
webencodings==0.5.1
|
| 187 |
+
websocket-client==1.8.0
|
| 188 |
+
werkzeug==3.1.3
|
| 189 |
+
widgetsnbextension==4.0.14
|
| 190 |
+
xxhash==3.5.0
|
| 191 |
+
yarl==1.20.1
|
| 192 |
+
zipp==3.22.0
|
| 193 |
+
# flash-attn==2.7.4.post1
|
| 194 |
+
hpsv3==1.0.0
|