lllyasviel/control_v11p_sd15_scribble · Hugging Face
もう少しで diffusers の ControlNet 完全制覇です。残すところあと4つ!
今回は Scribble を使ってみます。
Scribble
Google 翻訳っと!
落書き
なるほど!
今回も controlnet_aux は必要です
!pip install -U controlnet_aux
投入画像の準備
from diffusers.utils import load_image from controlnet_aux import HEDdetector init_image_url = "https://huggingface.co/lllyasviel/control_v11p_sd15_scribble/resolve/main/images/input.png" init_image = load_image(init_image_url) processor = HEDdetector.from_pretrained('lllyasviel/Annotators') control_image = processor(init_image, scribble=True)
scribble=True
の部分がやっぱり気になる。消してみたらどうなるか?
なるほど!
ControlNet, Pipeline の準備
import torch from diffusers import ControlNetModel, StableDiffusionControlNetPipeline, UniPCMultistepScheduler # ControlNet の準備 controlnet = ControlNetModel.from_pretrained( "lllyasviel/control_v11p_sd15_scribble", torch_dtype=torch.float16 ) # Pipeline の準備 pipe = StableDiffusionControlNetPipeline.from_pretrained( "runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, controlnet=controlnet ) pipe.enable_model_cpu_offload() # スケジューラーの設定 pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
変わり映えの無いいつものやつ
パイプライン実行
prompt = "royal chamber with fancy bed" image = pipe( prompt, num_inference_steps=30, generator=torch.manual_seed(0), image=control_image ).images[0] image
まとめ
scribble=True
scribble=False
そういえば
Model Card 上の生成物とは全然違いましたね。
クオリティが高すぎて、全然気にしてませんでした。