DPO LoRA Stable Diffusion XL Turbo
Model trained with LoRA implementation of Diffusion DPO Read more here
Base Model: https://hf-mirror.com/stabilityai/sdxl-turbo
Running with ? diffusers library
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)
shiroppo/sdxlturbo_lora
|sdxlturbolorav1-128dim.safetensors |787 MB| |sdxlturbolorav1-16dim.safetensors |98.7 MB| |sdxlturbolorav1-64dim.safetensors |394 MB|
LoRA based on Stability AI SDXL-Turbo, for more information on the main model: https://hf-mirror.com/stabilityai/sdxl-turboxyz_grid-0015-2494203713-20231201144837.png
Diffusers pip install diffusers transformers accelerate --upgrade
Text-to-image:
import torch
from diffusers import LCMScheduler, AutoPipelineForText2Image
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
adapter_id = "shiroppo/sd_xl_turbo_lora"
pipe = AutoPipelineForText2Image.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16")
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.to("cuda")
pipe.load_lora_weights(adapter_id)
pipe.fuse_lora()
prompt = "the_prompt"
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0).images[0]
评论