Views
No views yet
1import torch
2from diffusers import AutoPipelineForText2Image, DPMSolverMultistepScheduler
3from diffusers.utils import make_image_grid
4
5pipe = AutoPipelineForText2Image.from_pretrained(
6 "stabilityai/stable-diffusion-xl-base-1.0",
7 torch_dtype=torch.float16,
8 use_safetensors=True,
9 variant="fp16",
10)
11pipe.scheduler = DPMSolverMultistepScheduler.from_config(
12 pipe.scheduler.config,
13 use_karras_sigmas=True,
14 algorithm_type="sde-dpmsolver++"
15)
16
17pipe.to("cuda");
18
19seed = 12341234123
20prompt = "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"
21negative_prompt = "3d render, cartoon, drawing, art, low light, blur, pixelated, low resolution, black and white"
22num_inference_steps = 40
23height = 1024
24width = height
25guidance_scale = 7.5
26
27pipe.unload_lora_weights()
28pipe.load_lora_weights(
29 "radames/sdxl-DPO-LoRA",
30 adapter_name="sdxl-dpo-lora",
31)
32pipe.set_adapters(["sdxl-dpo-lora"], adapter_weights=[0.9])
33generator = torch.Generator().manual_seed(seed)
34with_dpo = pipe(
35 prompt=prompt,
36 guidance_scale=guidance_scale,
37 negative_prompt=negative_prompt,
38 num_inference_steps=num_inference_steps,
39 width=width,
40 height=height,
41 generator=generator,
42 ).images[0]
43with_dpo