sdsdgwe commited on
Commit
0dbe4fa
Β·
1 Parent(s): dcbdbe2
Files changed (1) hide show
  1. README.md +10 -384
README.md CHANGED
@@ -1,387 +1,13 @@
1
- <div align="center">
2
-
3
- # HPSv3: Towards Wide-Spectrum Human Preference Score (ICCV 2025)
4
-
5
- [![Project Website](https://img.shields.io/badge/🌐-Project%20Website-deepgray)](https://mizzenai.github.io/HPSv3.project/)
6
- [![arXiv](https://img.shields.io/badge/arXiv-2508.03789-b31b1b.svg)](https://arxiv.org/abs/2508.03789)
7
- [![ICCV 2025](https://img.shields.io/badge/ICCV-2025-blue.svg)](https://arxiv.org/abs/2508.03789)
8
- [![Model](https://img.shields.io/badge/πŸ€—-Model-yellow)](https://huggingface.co/MizzenAI/HPSv3)
9
- [![Dataset](https://img.shields.io/badge/πŸ€—-Dataset-green)](https://huggingface.co/datasets/MizzenAI/HPDv3)
10
- [![PyPI](https://img.shields.io/pypi/v/hpsv3)](https://pypi.org/project/hpsv3/)
11
-
12
- **Yuhang Ma**<sup>1,3*</sup>&ensp; **Yunhao Shui**<sup>1,4*</sup>&ensp; **Xiaoshi Wu**<sup>2</sup>&ensp; **Keqiang Sun**<sup>1,2†</sup>&ensp; **Hongsheng Li**<sup>2,5,6†</sup>
13
-
14
- <sup>1</sup>Mizzen AI&ensp;&ensp; <sup>2</sup>CUHK MMLab&ensp;&ensp; <sup>3</sup>King’s College London&ensp;&ensp; <sup>4</sup>Shanghai Jiaotong University&ensp;&ensp;
15
-
16
- <sup>5</sup>Shanghai AI Laboratory&ensp;&ensp; <sup>6</sup>CPII, InnoHK&ensp;&ensp;
17
-
18
- <sup>*</sup>Equal Contribution&ensp; <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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: HPSv3
3
+ emoji: 😻
4
+ colorFrom: red
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 5.42.0
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: HPSv3 demo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference