【 Stable Diffusion WebUI 】【Model】ControlNet

基本介紹

之前使用 txt2img 或 img2img,即使使用相同的 prompt

人物的動作,構圖也會跟著變化

ControlNet 這模型可以將圖片的動作及構圖固定

再根據 prompt 產出圖片

安裝

首先在 Extensions 安裝 ControlNet 套件

在 Url 中輸入 : https://github.com/Mikubill/sd-webui-controlnet 並按 Install

檢查是否安裝成功

再到 txt2img 和 img2img 底下看是否有出現 ControlNet 選項,如果有出現表示套件安裝成功

接下來要下載模型 : https://huggingface.co/lllyasviel/ControlNet/tree/main/models

這邊有 8 種模型,可以依照需求自行下載

把下載模型放到 stable-diffusion-webui\extensions\sd-webui-controlnet\models 底下

PS:要使用 segmentation 功能需要執行以下步驟

使用

不同模型可應用在不同地方,詳細可參考以下網址

https://github.com/lllyasviel/ControlNet
https://github.com/Mikubill/sd-webui-controlnet

canny : 產生線條搞

切換到 txt2img,上面 prompt 都不需要填,下面 ControlNet 選 canny,其他設定如下

下方測試圖片路徑可以參考 : \\stable-diffusion-webui\extensions\sd-webui-controlnet\samples

接著按 Generate 即可

depth : 深度資料圖

hed : HED (Holistically-Nested Edge Detection)

msle : M-LSD(Line Segment Detector) 直線提取算法

這邊換張圖效果比較好

產生

normal_map : Normal Map (法線紋理)

這邊換一張鋼鐵人的圖效果比較好

openpose : 輸出骨架

可以自行調整動作
https://webapp.magicposer.com/
https://app.posemy.art/
https://app.justsketch.me/

這邊可以注意一下

如果你本身是有一張圖,你想模仿圖中人的動作,你可以設定

Preprocessor 和 Model 都用 openpose

Preprocessor 會先根據你的圖算出骨架,再用 openpose model 產出圖

但假設你已經有骨架圖了,你可以設定

Preprocessor 為 none,Model 設為 openpose

表示你不需要先對圖算出骨架,因為你傳入的圖已經是骨架了

可以直接根據骨架圖用 model 來產圖