Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1 |
---
|
2 |
license: cc-by-nc-sa-4.0
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: cc-by-nc-sa-4.0
|
3 |
---
|
4 |
+
|
5 |
+
# Enhancing Diffusion Models with Text-Encoder Reinforcement Learning
|
6 |
+
|
7 |
+
Official PyTorch codes for paper [Enhancing Diffusion Models with Text-Encoder Reinforcement Learning](https://arxiv.org/abs/2311.15657)
|
8 |
+
|
9 |
+
## Results on SD-Turbo
|
10 |
+
|
11 |
+
We applied our method to the recent model [sdturbo](https://huggingface.co/stabilityai/sd-turbo). The model is trained with [Q-Instruct](https://github.com/Q-Future/Q-Instruct) feedback through direct back-propagation to save training time. Test with the following codes
|
12 |
+
|
13 |
+
```
|
14 |
+
## Note: sdturbo requires latest diffusers>=0.24.0 with AutoPipelineForText2Image class
|
15 |
+
|
16 |
+
from diffusers import AutoPipelineForText2Image
|
17 |
+
from peft import PeftModel
|
18 |
+
import torch
|
19 |
+
|
20 |
+
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sd-turbo", torch_dtype=torch.float16, variant="fp16")
|
21 |
+
pipe = pipe.to("cuda")
|
22 |
+
PeftModel.from_pretrained(pipe.text_encoder, 'chaofengc/sd-turbo_texforce')
|
23 |
+
|
24 |
+
pt = ['a photo of a cat.']
|
25 |
+
img = pipe(prompt=pt, num_inference_steps=1, guidance_scale=0.0).images[0]
|
26 |
+
```
|
27 |
+
|
28 |
+
![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6304798d41387c7f117558f7/aVmOs_C8CSBGfrgCserck.jpeg)
|
29 |
+
|