Views
No views yet
1# Load the VAE
2vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16, use_safetensors=True)
3
4base = DiffusionPipeline.from_pretrained(
5 "stabilityai/stable-diffusion-xl-base-1.0",
6 torch_dtype=torch.float16,
7 vae=vae,
8 # tokenizer=tokenizer,
9 variant="fp16",
10).to("cuda") # .to("cpu")
11
12# Load the scheduler
13base.scheduler = EulerDiscreteScheduler.from_config(base.scheduler.config)
14
15# Load the LoRA
16base.load_lora_weights("kishlaykumar1995/blinky-sdxl-dbooth-lora-32-1k")
17
18# Generate an image with 75 inference steps
19prompt = "A sks cartoon character driving a luxury car"
20negative_prompt = "blurry, broken, distorted"
21
22# Set the LoRA scale
23lora_scale = 0.8
24
25# Number of steps
26num_inference_steps=75
27
28# Guidance scale
29guidance_scale = 18.5
30
31# Load the scheduler
32base.scheduler = EulerDiscreteScheduler.from_config(base.scheduler.config)
33
34# Create a generator and set the seed
35generator = torch.Generator(device="cuda").manual_seed(16312)
36
37# Generate the output image
38output = base(prompt=prompt, num_inference_steps=num_inference_steps, generator=generator,
39 negative_prompt=negative_prompt, guidance_scale=guidance_scale,
40 cross_attention_kwargs={"scale": lora_scale})