目的
- Stable Diffusionを使って手書きの線画の清書と着色に挑戦した記録です
- トライアルですので良い方法があれば更新したいです
- 着色時にControlNetのUnit1を活用することを発見(2023/11/05)
参考サイト
ControlNetの概要と導入方法
線画と清書に関する先行記事
作例
parameters
masterpiece, single, profile, white hair, capelet, cat ears, kimono, japanese traditional clothes, earrings, white gloves, greyscale, beret, long sleeves, open mouth, short hair, white background, simple background, monochrome, white background
Negative prompt: EasyNegativeV2
Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 573102142, Size: 512x512, Model hash: 54ef3e3610, Model: meinamix_meinaV11, Denoising strength: 0.7, ControlNet 0: "Module: invert (from white bg & black line), Model: control_scribble-fp16 [c508311e], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced", Hires upscale: 2, Hires upscaler: Latent, TI hashes: "EasyNegativeV2: 339cc9210f70", Version: v1.6.0
parameters
masterpiece, single, alone, profile, white blue gray hair, navy blue hair inner color, blue eyes, white clothes, blue capelet, white blue gray cat ears, kimono, japanese traditional clothes, earrings, white gloves, white beret, long sleeves, open mouth, short hair, black obi, black sash belt, black band, simple background, white backgorund
Negative prompt: EasyNegativeV2
Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 3801738293, Size: 512x512, Model hash: 54ef3e3610, Model: meinamix_meinaV11, Denoising strength: 0.71, ControlNet 0: "Module: canny, Model: control_canny-fp16 [e3fe7712], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Threshold A: 100, Threshold B: 200, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced", ControlNet 1: "Module: invert (from white bg & black line), Model: control_scribble-fp16 [c508311e], Weight: 1, Resize Mode: Crop and Resize, Low Vram: False, Processor Res: 512, Guidance Start: 0, Guidance End: 1, Pixel Perfect: False, Control Mode: Balanced", Hires upscale: 2, Hires upscaler: Latent, TI hashes: "EasyNegativeV2: 339cc9210f70", Version: v1.6.0
前提条件
- 参考サイトに基づきControlNetを導入します
- 今回はscribbleとcannyを導入します
線画の清書
Interrogate DeepBooruでプロンプト案を作ってControlNetから清書を出力
-
img2imgタブに手書きの線画をロード
-
内容を確認して必要な内容を追加してコピー
今回はprofile (横顔), 着物関連を追記, 服装関連はできる限り書いたほうが良いっぽい -
txt2imgタブのプロンプトに3の内容を入力
-
Generationタブの下部にあるControlNetの"ControlNet Unit 0"の"Enable"を選択
-
手書きの線画をロード
-
Preprocessorに"invert(from white bg & black line)", Modelに"control_scribble-fp16"を選択
- Preprocessorに”scribble_head”などを選ぶと下絵から比較的変形したものが出力される
→ 大まかなラフから一気に清書を出力するのに有効と思われる - 今回は手書きの線画により近いものを出力するために"invert"を選択
- Preprocessorに”scribble_head”などを選ぶと下絵から比較的変形したものが出力される
-
Generateで画像を生成し、良い画像を選定
線画の着色
txt2imgにあるControlNetのUnit0, Unit1の2か所を設定する
- "ControlNet Unit 0"の"Enable"を選択
- 上記で生成した線画の清書をロード
- Control Typeで"Canny"を選択
- Preprocessorに"canny", Modelに"control_canny-fp16"を選択
- "ControlNet Unit 1"の"Enable"を選択
- 手書きの線画をロード
- Preprocessorに"invert(from white bg & black line)", Modelに"control_scribble-fp16"を選択
- Generateで画像を生成し、良い画像を選定
着色におけるControlNet Unit1の効果
- 生成された画像の例で比較
- Unit1を設定することで手書きの雰囲気をかなり残すことが可能になる
- Unit1を設定しないとモデルに引っ張られている様子
- 現時点では機能の理解はできていないため結果論のみ
Unit1 あり | Unit1 なし |
---|---|
![]() |
![]() |
最後に
絵心がなく線画を詰め切れない状況で、きれいな清書を出力できるのは非常にありがたいです
着色については、部分修正など新たな技術も導入してさらに狙ったものに近づけたいと考えています