--- library_name: diffusers pipeline_tag: text-to-image inference: true base_model: stabilityai/sdxl-turbo --- # DPO LoRA Stable Diffusion XL Turbo 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/sdxl-turbo ## Running with [🧨 diffusers library](https://github.com/huggingface/diffusers) ```python from diffusers import DiffusionPipeline from diffusers.utils import make_image_grid import torch pipe = DiffusionPipeline.from_pretrained( "stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16" ) pipe.to("cuda") pipe.load_lora_weights("radames/sdxl-turbo-DPO-LoRA", adapter_name="dpo-lora-sdxl-turbo") pipe.set_adapters(["dpo-lora-sdxl-turbo"], adapter_weights=[1.0]) # you can play with adapter_weights to increase the effect of the LoRA model seed = 123123 prompt = " A photo of beautiful mountain with realistic sunset and blue lake, highly detailed, masterpiece" negative_prompt = "3d render, cartoon, drawing, art, low light, blur, pixelated, low resolution, black and white, old photo, blurry faces" generator = torch.Generator().manual_seed(seed) images = pipe( prompt=prompt, negative_prompt=negative_prompt, width=512, height=512, num_inference_steps=2, generator=generator, guidance_scale=1.0, num_images_per_prompt=4 ).images make_image_grid(images, 1, 4) ``` ## Guidance Scale vs LoRA weights ![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/TJJx9RYlML14angWGRhmv.jpeg) ## Examples Left Withoud DPO right with DPO LoRA ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/oTTUkjXMciHBe__l75AOm.png) ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/rA1Pj5nzyI5d-SNpAz5rN.png) ### ComfyUI [![](https://cdn-uploads.huggingface.co/production/uploads/6064e095abd8d3692e3e2ed6/5zpLoCGuKXj87mqe5g4jt.jpeg)](https://huggingface.co/radames/sdxl-turbo-DPO-LoRA/raw/main/comfyui-workflow-sdxl-turbo-lora-dpo.json) https://huggingface.co/radames/sdxl-turbo-DPO-LoRA/raw/main/comfyui-workflow-sdxl-turbo-lora-dpo.json