Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
library_name: diffusers
|
3 |
+
pipeline_tag: text-to-image
|
4 |
+
inference: true
|
5 |
+
base_model: stabilityai/sdxl-turbo
|
6 |
+
---
|
7 |
+
# DPO LoRA Stable Diffusion XL Turbo
|
8 |
+
Model trained with LoRA implementation of Diffusion DPO Read more [here](https://github.com/huggingface/diffusers/tree/main/examples/research_projects/diffusion_dpo)
|
9 |
+
|
10 |
+
|
11 |
+
Base Model: https://huggingface.co/stabilityai/sdxl-turbo
|
12 |
+
|
13 |
+
## Running with [🧨 diffusers library](https://github.com/huggingface/diffusers)
|
14 |
+
|
15 |
+
|
16 |
+
```python
|
17 |
+
|
18 |
+
from diffusers import DiffusionPipeline
|
19 |
+
from diffusers.utils import make_image_grid
|
20 |
+
import torch
|
21 |
+
|
22 |
+
pipe = DiffusionPipeline.from_pretrained(
|
23 |
+
"stabilityai/sdxl-turbo",
|
24 |
+
torch_dtype=torch.float16, variant="fp16"
|
25 |
+
)
|
26 |
+
pipe.to("cuda")
|
27 |
+
pipe.load_lora_weights("radames/sdxl-turbo-DPO-LoRA", adapter_name="dpo-lora-sd21")
|
28 |
+
pipe.set_adapters(["dpo-lora-sd21"], adapter_weights=[1.0]) # you can play with adapter_weights to increase the effect of the LoRA model
|
29 |
+
seed = 123123
|
30 |
+
prompt = "portrait headshot professional of elon musk"
|
31 |
+
negative_prompt = "3d render, cartoon, drawing, art, low light"
|
32 |
+
generator = torch.Generator().manual_seed(seed)
|
33 |
+
images = pipe(
|
34 |
+
prompt=prompt,
|
35 |
+
negative_prompt=negative_prompt,
|
36 |
+
width=512,
|
37 |
+
height=512,
|
38 |
+
num_inference_steps=2,
|
39 |
+
generator=generator,
|
40 |
+
guidance_scale=1.0,
|
41 |
+
num_images_per_prompt=4
|
42 |
+
).images
|
43 |
+
make_image_grid(images, 1, 4)
|
44 |
+
```
|
45 |
+
|
46 |
+
## Guidance Scale vs LoRA weights
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
|
51 |
+
## Examples
|
52 |
+
|
53 |
+
Left Withoud DPO right with DPO LoRA
|