JTTJ commited on
Commit
848488f
·
verified ·
1 Parent(s): d27b877

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +92 -3
README.md CHANGED
@@ -1,3 +1,92 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GradSPO: A Gradient Guidance Perspective on Stepwise Preference Optimization for Diffusion Models
2
+
3
+
4
+ This repository provides **public LoRA checkpoints trained with GradSPO** for **Stable Diffusion v1.5** and **SDXL**.
5
+
6
+ **GradSPO** reframes **stepwise preference optimization (SPO)** as learning from **noisy reward signals**, explicitly reducing this noise through **gradient guidance**. This results in **stronger reward signals** and achieves **improved preference alignment**.
7
+
8
+ All released checkpoints are **LoRA weights only** and must be loaded on top of their corresponding base models.
9
+
10
+ The official training code is available at:
11
+ https://github.com/JoshuaTTJ/GradSPO
12
+
13
+ ---
14
+
15
+ ## Usage
16
+
17
+ ### SDXL (LoRA)
18
+
19
+ ```python
20
+ from diffusers import StableDiffusionXLPipeline
21
+ import torch
22
+
23
+ pipe = StableDiffusionXLPipeline.from_pretrained(
24
+ "stabilityai/stable-diffusion-xl-base-1.0",
25
+ torch_dtype=torch.float16,
26
+ )
27
+
28
+ pipe.load_lora_weights("./sd1_5")
29
+
30
+ pipe = pipe.to("cuda")
31
+
32
+ prompt = "A cat holding a sign that says hello world"
33
+
34
+ generator = torch.Generator(device="cuda").manual_seed(42)
35
+ image = pipe(
36
+ prompt=prompt,
37
+ guidance_scale=5.0,
38
+ num_inference_steps=20,
39
+ generator=generator,
40
+ output_type="pil",
41
+ ).images[0]
42
+
43
+ image.save("img_sdxl.png")
44
+ ```
45
+
46
+ ---
47
+
48
+ ### Stable Diffusion v1.5 (LoRA)
49
+
50
+ ```python
51
+ from diffusers import StableDiffusionPipeline
52
+ import torch
53
+
54
+ pipe = StableDiffusionPipeline.from_pretrained(
55
+ "sd-legacy/stable-diffusion-v1-5",
56
+ torch_dtype=torch.float16,
57
+ )
58
+
59
+ pipe.load_lora_weights("./sdxl")
60
+
61
+ pipe = pipe.to("cuda")
62
+
63
+ prompt = "a photo of a cat"
64
+
65
+ generator = torch.Generator(device="cuda").manual_seed(42)
66
+ image = pipe(
67
+ prompt=prompt,
68
+ guidance_scale=5.0,
69
+ num_inference_steps=20,
70
+ generator=generator,
71
+ output_type="pil",
72
+ ).images[0]
73
+
74
+ image.save("img_sd15.png")
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Citation
80
+
81
+ If you find GradSPO useful in your research, please consider citing our work:
82
+
83
+ ```bibtex
84
+ @inproceedings{
85
+ tee2025a,
86
+ title={A Gradient Guidance Perspective on Stepwise Preference Optimization for Diffusion Models},
87
+ author={Joshua Tian Jin Tee and Hee Suk Yoon and Abu Hanif Muhammad Syarubany and Eunseop Yoon and Chang D. Yoo},
88
+ booktitle={The Thirty-ninth Annual Conference on Neural Information Processing Systems},
89
+ year={2025},
90
+ url={https://openreview.net/forum?id=d6lIOnvOX2}
91
+ }
92
+ ```