最も簡単な方法:Diffusersライブラリを使う
1. Google Colabを開く
colab.research.google.com にアクセス
「ファイル」→「ノートブックを新規作成」
2. GPUを有効化
「ランタイム」→「ランタイムのタイプを変更」
「ハードウェアアクセラレータ」を T4 GPU に設定
!pip install diffusers transformers accelerate
from diffusers import StableDiffusionPipeline
import torch
# モデルの読み込み(初回は数分かかります)
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16
)
pipe = pipe.to("cuda")
# 画像生成
prompt = "a beautiful sunset over the ocean, highly detailed"
image = pipe(prompt).images[0]
# 画像を表示
image

A young woman in a business suit, standing in a modern office, cinematic lighting, hyperrealistic, 8k, sharp focus, photo taken by Canon EOS R5

UI上でやらないといけないのね。まぁちょっと理解した。