![見出し画像](https://assets.st-note.com/production/uploads/images/122230420/rectangle_large_type_2_4b39cef1fc121b4623d4164dbc2c13ba.png?width=800)
Google Colabでlcm-lora-sdxlを使いAIイラストを作成してみた
推論ステップを2から8までに減らすことができるlcm-lora-sdxlを使ってみました。つまり素早く画像生成が出来ますというのが売りとなります。
上記ページを参考にGoogle Colabで動かしてみました。サクッとできますので良いですね。
promptは、8k画像で、黄金色の髪を持つ美しいサイボーグを描いて下さいとなっています。
!pip install --upgrade pip
!pip install --upgrade diffusers transformers accelerate peft
import torch
from diffusers import LCMScheduler, AutoPipelineForText2Image
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
adapter_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")
# load and fuse lcm lora
pipe.load_lora_weights(adapter_id)
pipe.fuse_lora()
prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
# disable guidance_scale by passing 0
image = pipe(prompt=prompt, num_inference_steps=4, guidance_scale=0).images[0]
image.save("image.png") # save image to disk
![](https://assets.st-note.com/img/1700476321649-LBuydNU8gJ.png?width=800)
![](https://assets.st-note.com/img/1700476397918-H6SrscStZt.png?width=800)
この記事が気に入ったらサポートをしてみませんか?