File size: 2,401 Bytes
5d3ef06 0659e6a 5d3ef06 5331cbb 5d3ef06 b250d42 5d3ef06 5331cbb b250d42 5331cbb b250d42 5331cbb 5d3ef06 5331cbb b250d42 5331cbb b250d42 5331cbb c60900c 5331cbb 5d3ef06 b250d42 5d3ef06 5331cbb 5d3ef06 5331cbb 5d3ef06 5331cbb 5d3ef06 b250d42 257f4cc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
---
library_name: diffusers
pipeline_tag: text-to-image
inference: true
base_model: stabilityai/stable-diffusion-xl-base-1.0
---
# DPO LoRA Stable Diffusion XL
Model trained with LoRA implementation of Diffusion DPO Read more [here](https://github.com/huggingface/diffusers/tree/main/examples/research_projects/diffusion_dpo)
Base Model: https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0
## Running with [🧨 diffusers library](https://github.com/huggingface/diffusers)
```python
import torch
from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler
from diffusers.utils import make_image_grid
pipe = AutoPipelineForText2Image.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float16,
use_safetensors=True,
variant="fp16",
)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(
pipe.scheduler.config,
use_karras_sigmas=True,
algorithm_type="sde-dpmsolver++"
)
pipe.to("cuda");
seed = 12341234123
prompt = "professional portrait photo of a girl, photograph, highly detailed face, depth of field, moody light, golden hour, style by Dan Winters, Russell James, Steve McCurry, centered, extremely detailed, Nikon D850, award winning photography"
negative_prompt = "3d render, cartoon, drawing, art, low light, blur, pixelated, low resolution, black and white"
num_inference_steps = 40
height = 1024
width = height
guidance_scale = 7.5
pipe.unload_lora_weights()
pipe.load_lora_weights(
"radames/sdxl-DPO-LoRA",
adapter_name="sdxl-dpo-lora",
)
pipe.set_adapters(["sdxl-dpo-lora"], adapter_weights=[0.9])
generator = torch.Generator().manual_seed(seed)
with_dpo = pipe(
prompt=prompt,
guidance_scale=guidance_scale,
negative_prompt=negative_prompt,
num_inference_steps=num_inference_steps,
width=width,
height=height,
generator=generator,
).images[0]
with_dpo
```
# Adaptor Weights effect
adapter_weights
![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/f69suGIl9Ysnmi52ahol8.jpeg)
## ComfyUI
[![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/SntSYkwyDVGESk4vlA920.jpeg)](https://huggingface.co/radames/sdxl-DPO-LoRA/raw/main/workflow-sdxl-dpo-lora.json)
https://huggingface.co/radames/sdxl-DPO-LoRA/raw/main/workflow-sdxl-dpo-lora.json |