Text-to-Image
Diffusers
Safetensors
FluxPipeline
Washakh commited on
Commit
584e262
·
verified ·
1 Parent(s): b911d0a

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +88 -0
README.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model:
3
+ - tencent/SRPO
4
+ library_name: diffusers
5
+ license: other
6
+ license_name: tencent-hunyuan-community
7
+ license_link: https://github.com/Tencent-Hunyuan/SRPO/blob/main/LICENSE.txt
8
+ pipeline_tag: text-to-image
9
+ ---
10
+
11
+ ## bf16 and (remaking FP8 version) versions of SRPO from Tencent
12
+
13
+ <div align="center" style="font-family: charter;">
14
+ <h1 align="center">Directly Aligning the Full Diffusion Trajectory with Fine-Grained Human Preference </h1>
15
+ <div align="center">
16
+ <a href='https://arxiv.org/abs/2509.06942'><img src='https://img.shields.io/badge/ArXiv-red?logo=arxiv'></a> &nbsp;
17
+ <a href='https://github.com/Tencent-Hunyuan/SRPO'><img src='https://img.shields.io/badge/_Code-SRPO-181717?color=121717&logo=github&logoColor=whitee'></a> &nbsp;
18
+ <a href='https://tencent.github.io/srpo-project-page/'><img src='https://img.shields.io/badge/%F0%9F%92%BB_Project-SRPO-blue'></a> &nbsp;
19
+ </div>
20
+ <div align="center">
21
+ Xiangwei Shen<sup>1,2*</sup>,
22
+ <a href="https://scholar.google.com/citations?user=Lnr1FQEAAAAJ&hl=zh-CN" target="_blank"><b>Zhimin Li</b></a><sup>1*</sup>,
23
+ <a href="https://scholar.google.com.hk/citations?user=Fz3X5FwAAAAJ" target="_blank"><b>Zhantao Yang</b></a><sup>1</sup>,
24
+ <a href="https://shiyi-zh0408.github.io/" target="_blank"><b>Shiyi Zhang</b></a><sup>3</sup>,
25
+ Yingfang Zhang<sup>1</sup>,
26
+ Donghao Li<sup>1</sup>,
27
+ <br>
28
+ <a href="https://scholar.google.com/citations?user=VXQV5xwAAAAJ&hl=en" target="_blank"><b>Chunyu Wang</b></a><sup>1</sup>,
29
+ <a href="https://openreview.net/profile?id=%7EQinglin_Lu2" target="_blank"><b>Qinglin Lu</b></a><sup>1</sup>,
30
+ <a href="https://andytang15.github.io" target="_blank"><b>Yansong Tang</b></a><sup>3,✝</sup>
31
+ </div>
32
+ <div align="center">
33
+ <sup>1</sup>Hunyuan, Tencent 
34
+ <br>
35
+ <sup>2</sup>School of Science and Engineering, The Chinese University of Hong Kong, Shenzhen 
36
+ <br>
37
+ <sup>3</sup>Shenzhen International Graduate School, Tsinghua University 
38
+ <br>
39
+ <sup>*</sup>Equal contribution 
40
+ <sup>✝</sup>Corresponding author
41
+ </div>
42
+ </div>
43
+
44
+
45
+ ## Abstract
46
+ Recent studies have demonstrated the effectiveness of directly aligning diffusion models with human preferences using differentiable reward. However, they exhibit two primary challenges: (1) they rely on multistep denoising with gradient computation for reward scoring, which is computationally expensive, thus restricting optimization to only a few diffusion steps; (2) they often need continuous offline adaptation of reward models in order to achieve desired aesthetic quality, such as photorealism or precise lighting effects. To address the limitation of multistep denoising, we propose Direct-Align, a method that predefines a noise prior to effectively recover original images from any time steps via interpolation, leveraging the equation that diffusion states are interpolations between noise and target images, which effectively avoids over-optimization in late timesteps. Furthermore, we introduce Semantic Relative Preference Optimization (SRPO), in which rewards are formulated as text-conditioned signals. This approach enables online adjustment of rewards in response to positive and negative prompt augmentation, thereby reducing the reliance on offline reward fine-tuning. By fine-tuning the FLUX.1.dev model with optimized denoising and online reward adjustment, we improve its human-evaluated realism and aesthetic quality by over 3x.
47
+
48
+ ## Quick Started
49
+ ### Checkpoints
50
+ The `diffusion_pytorch_model.safetensors` is online version of SRPO based on [FLUX.1 Dev](https://huggingface.co/black-forest-labs/FLUX.1-dev), trained on HPD dataset with [HPSv2](https://github.com/tgxs002/HPSv2)
51
+
52
+ #### Inference
53
+ Replace the `diffusion_pytorch_model.safetensors` of FLUX
54
+ ```python
55
+ from diffusers import FluxPipeline
56
+ prompt='The Death of Ophelia by John Everett Millais, Pre-Raphaelite painting, Ophelia floating in a river surrounded by flowers, detailed natural elements, melancholic and tragic atmosphere'
57
+ pipe = FluxPipeline.from_pretrained('./data/flux',
58
+ torch_dtype=torch.bfloat16,
59
+ use_safetensors=True
60
+ ).to("cuda")
61
+ state_dict = load_file("./srpo/diffusion_pytorch_model.safetensors")
62
+ pipe.transformer.load_state_dict(state_dict)
63
+ image = pipe(
64
+ prompt,
65
+ guidance_scale=3.5,
66
+ height=1024,
67
+ width=1024,
68
+ num_inference_steps=infer_step,
69
+ max_sequence_length=512,
70
+ generator=generator
71
+ ).images[0]
72
+ ```
73
+ ### License
74
+ SRPO is licensed under the License Terms of SRPO. See `./License.txt` for more details.
75
+ ## Citation
76
+ If you use SRPO for your research, please cite our paper:
77
+
78
+ ```bibtex
79
+ @misc{shen2025directlyaligningdiffusiontrajectory,
80
+ title={Directly Aligning the Full Diffusion Trajectory with Fine-Grained Human Preference},
81
+ author={Xiangwei Shen and Zhimin Li and Zhantao Yang and Shiyi Zhang and Yingfang Zhang and Donghao Li and Chunyu Wang and Qinglin Lu and Yansong Tang},
82
+ year={2025},
83
+ eprint={2509.06942},
84
+ archivePrefix={arXiv},
85
+ primaryClass={cs.AI},\
86
+ url={https://arxiv.org/abs/2509.06942},
87
+ }
88
+ ```