ComfyUI 輕鬆轉換不同 Style

有用過 Fooocus 的用家都會覺得可以隨意選擇風格很方便,不用每次自己設定 prompts,其實在 ComfyUI 也可以安裝 SDXL Prompt Styler 來實現。


安裝 SDXL Prompt Styler

  • 在 ComfyUI 目錄打開 teriminal
  • 進入 ComfyUI/custom_nodes 資料夾
  • 用 git 下載文件 git clone https://github.com/twri/sdxl_prompt_styler.git
  • 啟動/重新啟動 ComfyUI
GitHub - twri/sdxl_prompt_styler: Custom prompt styler node for SDXL in ComfyUI
Custom prompt styler node for SDXL in ComfyUI. Contribute to twri/sdxl_prompt_styler development by creating an account on GitHub.

使用方法

新增 SDXL Prompt Styler node
  • Add Node > utils > SDXL Prompt Styler
SDXL Prompt Styler

第一個方格是自訂的 prompt,第二個方格是自訂的 negative prompt,style 是選擇不同的風格 base 是沒有風格。也可以將 prompt 及 negative prompt 轉成經 node 輸入,右 click SDXL Prompt Styler,選擇 Convert text_positive to input 及 Convert text_negatice to input。

將 prompt 轉成 input

新增 Primitive Node

  • Add Node > utils > Primitive
新增 Primitive Node

將 Primitive Node 連到 text_positive input 就會變成 string,可輸入 prompt。

連到 text_positive
prompt 及 negative prompt 各一即可
將 SDXL Prompt Styler 加入到整個流程

想使用以上 workflow 可以下載以下 file。

想了解更多風格可以參考這篇,我有為每一個風格生成參考圖。

簡易版 StableDiffusionWebUI - Fooocus
StableDiffusionWebUI 雖然功能強大,但更多人喜歡 Midjourney 單純用 prompt 的簡易操作方式。StableDiffusionWebUI 最具代表性的 extension - ControlNet 的作者 lllyasviel 重新構思 Stable Diffusion 後推出了這個新軟件 Fooocus。

自訂風格

如果有一些喜歡的風格 prompt 其實也可以在 SDXL Prompt Styler 中加入自訂風格,方便記錄及以後重用。

開一個新.json file
  • 首先在 ComfyUI/custom_nodes/sdxl_prompt_styler/ 資料夾中生增一個新的 json 檔,我將此 file 命名為 sdxl_styles_edmond.json。
加入原創的 prompt
  • 然後依以上格式加入 prompt, name 是在 node 中顯示的名稱, prompt 就是主要 prompt,當中的 {prompt} 是指在 node input 的 prompt。 negative_prompt 就是 negative prompt。
  • 儲存後重啟 ComfyUI。
在 style 中即可以選擇新自訂的 style
  • 然後在 SDXL Prompt Styler 中就可以選擇新的 style 了。
使用自訂的 style 生成圖片

總結

有 SDXL Prompt Styler 後可以更簡單生成不同風格的圖片,可以節省很多找風格 prompt 的時間。