Views
No views yet
1
2from diffusers import DiffusionPipeline
3from diffusers.utils import make_image_grid
4import torch
5
6pipe = DiffusionPipeline.from_pretrained(
7 "stabilityai/sdxl-turbo",
8 torch_dtype=torch.float16, variant="fp16"
9)
10pipe.to("cuda")
11pipe.load_lora_weights("radames/sdxl-turbo-DPO-LoRA", adapter_name="dpo-lora-sdxl-turbo")
12pipe.set_adapters(["dpo-lora-sdxl-turbo"], adapter_weights=[1.0]) # you can play with adapter_weights to increase the effect of the LoRA model
13seed = 123123
14prompt = " A photo of beautiful mountain with realistic sunset and blue lake, highly detailed, masterpiece"
15negative_prompt = "3d render, cartoon, drawing, art, low light, blur, pixelated, low resolution, black and white, old photo, blurry faces"
16generator = torch.Generator().manual_seed(seed)
17images = pipe(
18 prompt=prompt,
19 negative_prompt=negative_prompt,
20 width=512,
21 height=512,
22 num_inference_steps=2,
23 generator=generator,
24 guidance_scale=1.0,
25 num_images_per_prompt=4
26).images
27make_image_grid(images, 1, 4)

