SkyOSFullCore / code_runner.py
sky-meilin's picture
Create code_runner.py
2ab5e01 verified
Raw
History Blame
639 Bytes
import torch
from diffusers import AutoPipelineForText2Image, LCMScheduler
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
lcm_lora_id = "latent-consistency/lcm-lora-sdxl"
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(lcm_lora_id)
pipe.fuse_lora()
prompt = "Sky Meilin, consistent AI persona, creator system, cinematic portrait"
image = pipe(
prompt=prompt,
num_inference_steps=4,
guidance_scale=1.5
).images[0]
image.save("sky_output.png")