Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- yuvalkirstain/pickapic_v2
|
4 |
+
---
|
5 |
+
# Diffusion Model Alignment Using Direct Preference Optimization
|
6 |
+
|
7 |
+
|
8 |
+
Direct Preference Optimization (DPO) for text-to-image diffusion models is a method to align diffusion models to text human preferences by directly optimizing on human comparison data. Please check our paper at [Diffusion Model Alignment Using Direct Preference Optimization](https://arxiv.org/abs/2311.12908).
|
9 |
+
|
10 |
+
This model is fine-tuned from [stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) on offline human preference data [pickapic_v2](https://huggingface.co/datasets/yuvalkirstain/pickapic_v2).
|
11 |
+
|
12 |
+
## Code
|
13 |
+
*Code will come soon!!!*
|
14 |
+
|
15 |
+
## SD1.5
|
16 |
+
We also have a model finedtuned from [stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) available at [dpo-sd1.5-text2image-v1](https://huggingface.co/mhdang/dpo-sd1.5-text2image-v1).
|
17 |
+
|
18 |
+
## A quick example
|
19 |
+
```python
|
20 |
+
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel
|
21 |
+
import torch
|
22 |
+
|
23 |
+
# load pipeline
|
24 |
+
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
25 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True).to("cuda")
|
26 |
+
|
27 |
+
# load finetuned model
|
28 |
+
unet_id = "mhdang/dpo-sdxl-text2image-v1"
|
29 |
+
unet = UNet2DConditionModel.from_pretrained(unet_id, subfolder="unet", torch_dtype=torch.float16)
|
30 |
+
pipe.unet = unet
|
31 |
+
pipe = pipe.to("cuda")
|
32 |
+
|
33 |
+
prompt = "Two cats playing chess on a tree branch"
|
34 |
+
image = pipe(prompt, guidance_scale=7.5).images[0].resize((512,512))
|
35 |
+
|
36 |
+
image.save("cats_playing_chess.png")
|
37 |
+
```
|
38 |
+
|
39 |
+
More details coming soon.
|