快速學會使用ComfyUI的技巧與方法

ComfyUI基礎操作

     為什麼要學ComfyUI?使用stable diffusion論新手友好,介面簡單,WebUI是大多數人的選擇,用戶只需設置好參數,即可等待最終的生成結果,即使是在電腦硬體設備較差的情況下,也還可以選擇Forge UI,Forge UI擁有和外部UI一樣的使用者介面和操作方法,但優化了顯存佔用和出圖效率。

     小提醒: 尚未安裝好環境的朋友,請先移駕到如何正確安裝Stable Diffusion這篇文章,SD及ComfyUI的工作環境是兼容的。

  ComfyUI是什麼?  

ComfyUI是一種可以幫助我們用電腦生成圖片的工具。它有一個簡單的界面,讓每個人都能使用,即使是剛開始學習的小朋友也能很快上手。

為什麼選擇ComfyUI

    1. 簡單易用:即使你是新手,只要設置好一些參數,就可以坐著等著看結果了。
    2. 靈活性高:你可以自己選擇不同的步驟,這樣就能創造出獨特的圖片。
    3. 低要求:即使你的電腦不是很強大,ComfyUI也能運行得很好。

如何使用ComfyUI

    • 使用ComfyUI時,你需要把不同的步驟連接在一起,這些步驟叫做「節點」。每個節點都有不同的功能,比如選擇圖片、調整顏色等。
    • 雖然一開始看起來有點複雜,相信就勸退了很多人,但我還是想向你推薦ComfyUI,並且我相信你一旦學會它,就一定會愛上它。

安裝ComfyUI

     我們一起來看看如何安裝ComfyUI,並設置必備的節點和工作流程吧!這個過程非常簡單,讓我們一步步來。

    1. 打開ComfyUIGitHub頁面:在頁面上向下滾動,找到安裝部分。
    2. 下載壓縮包:只需點擊下載,然後解壓縮這個包。
Snipaste_2024-11-09_00-08-45

3. 執行ComfyUI

     找到裡面的run_nvidia_gpu.bat(如果你有NVIDIA顯卡)或run_cpu.bat(如果沒有顯卡),雙擊它即可啟動ComfyUI。

Snipaste_2024-11-09_00-10-19

4. 安裝模型檔

        要使用ComfyUI生成圖片,我們需要一些模型檔。這些模型檔可以從不同的網站下載,例如Civitai。下載後,將模型檔放入以下資料夾中:

路徑:ComfyUI── models── checkpoints

5. 設置模型共用

        如果你還有其他的AI工具(例如Web UI),可以讓ComfyUI和它們共用模型檔。具體步驟如下:

1. 在ComfyUI資料夾找到extra_model_paths.yaml.example文件,用記事本打開。

2. 將base_path後面的路徑改成Web UI的模型資料夾路徑,然後保存文件。

3. 刪除文件名後面的.example,這樣就完成了共用設置。

Snipaste_2024-11-09_00-14-16

安裝必備節點

     為了更好地使用ComfyUI,我們需要安裝三個必備的節點:

      1. ComfyUI Manager:可以幫助你安裝、刪除和管理其他節點。
      2. ComfyUI Translation:可以將介面語言轉換為中文,讓使用更方便。
      3. ComfyUI Workspace Manager:幫助你管理模型和工作流程。
點選Custom Nodes Manager
點選Custom Nodes Manager
直接搜尋後安裝即可
直接搜尋後安裝即可
可將語言改為中文
可將語言改為中文

建立文生圖工作流程

     現在你已經安裝好了所有必備的節點,可以開始搭建自己的第一個基本文生圖工作流程了!在左側的工作區,你會看到一個預設的工作流程,可以根據需要進行修改和擴展。

    • 首先,點擊右側的清除按鈕,清空現有的工作流。
    • 在空白處右鍵點擊,選擇「添加節點」,然後選擇「採樣器」。
選擇K採樣器
選擇K採樣器
ComfyUI的起手式就由K採樣器開始
ComfyUI的起手式就由K採樣器開始

在採樣器中,有幾個重要的參數需要設置:

  • 隨機種子:這是生成每張圖時使用的數值,默認為0。(也就是SD中的seed值)
  • 執行後操作:這可以設置為固定、增加、減少或隨機,決定每次生成圖時種子的變化。
  • 步數:通常設置在20~30左右,表示反覆運算的次數。
  • CFG:這是提示詞相關性的數值,越大越接近提示詞效果,通常保持預設值8即可。

接下來,我們需要將其他節點連接到採樣器。每一個節點都要有各自的

直接拖拉
直接拖拉
選擇載入大模型
選擇載入大模型
採樣器說明
採樣器說明
    1. 模型 (Checkpoint):這是生成圖片的核心部分。
    2. 正面提示詞 (CLIP文本編碼器):告訴AI你想要生成什麼樣的圖片。
    3. 負面提示詞 (CLIP文本編碼器):告訴AI不想要哪些元素。
    4. latent:用來設置生成圖片的成果。
另存此圖後可直接匯入ComfyUI
另存此圖後可直接匯入ComfyUI
測試工作流
    • 當所有節點都正確連接後,我們可以添加提示詞佇列進行出圖測試。
    • 如果出現紅框或紅點提示,表示某些節點沒有正確連接,需要檢查並修正。

完成搭建

    • 一旦所有節點都正確連接且沒有錯誤提示,你就成功搭建了一個文生圖工作流!現在可以開始生成你想要的圖片了。

這些步驟聽起來可能有些複雜,但只要按照指示操作,就能輕鬆搭建自己的工作流。快去嘗試一下吧!

建立圖生圖工作流程

     當我們想使用ComfyUI進行圖生圖的生成時,搭建工作流的步驟與文生圖相似,但需要額外添加參考圖像。以下是如何搭建這個工作流的詳細步驟。

1. 添加載入圖像節點

     右鍵點擊空白處,選擇「新建節點」,然後選擇「載入圖像」。將參考圖片上傳到這個節點中。

2. 連接節點

     載入圖像節點只有輸出端,從這裡拖出連接線,選擇「VAE編碼」節點。這一步是將載入的圖像資訊轉化為AI可以理解的格式,並傳遞給採樣器

3. 設置採樣器

     在工作流中添加採樣器節點,並設置必要的參數,如隨機種子、運行後操作和步數。這些參數將影響生成圖片的質量和風格。

4. 連接VAE解碼和輸出

     將VAE編碼的輸出連接到大模型的VAE接著,可以選擇將生成的圖片預覽或直接保存。若選擇預覽,則需要手動保存圖片;若選擇保存,則會自動保存到指定資料夾。

5. 調整降噪參數

     降噪參數(類似於外部UI中的重繪幅度)決定生成圖片與參考圖之間的相似度。數值越低,生成的圖片越接近參考圖;數值越高,則更隨意發揮。可以設置為0.75進行測試。

6. 圖像尺寸設置

     若希望生成的圖片尺寸與參考圖不同,可以在載入圖像後添加「圖像縮放」節點。

保存和加載工作流

     完成搭建後,可以將工作流保存到本地,下次使用時直接加載即可。如果只生成了一張圖片,也可以將其拖進工作區,自動恢復之前的工作流。 

自行設定
自行設定
  1. 使用Derfuu外掛程式進行簡化操作

     安裝Derfuu外掛程式後,可以使用「Image scale to side」節點來更方便地調整圖片尺寸,而不需要手動計算比例。

使用Derfuu外掛
使用Derfuu外掛

      通過以上步驟,你應該能夠順利搭建一個功能完善的圖生圖工作流。隨著實踐,你會越來越熟悉ComfyUI的操作,也能創造出更多有趣的作品! 

 

如何取得ComfyUI工作流

      網路上有很多網站分享ComfyUI工作流程,例如:

  回分類目錄或是繼續下一章節 – 了解什麼是ComfyUI工作流

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作  

Google    瑆知識

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

ComfyUI基礎操作  ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 ComfyUI基礎操作 

h1: The Secret Garden

h2: Chapter 1 – The Discovery

h3: A Hidden Door

In the heart of the old mansion, young Amelia stumbled upon a mysterious, overgrown door. The mansion, a place she had inherited from a distant relative, held many secrets, but this door seemed to beckon her with an irresistible charm.

h3: The Key

After days of searching, Amelia found an old brass key that perfectly fit the lock of the hidden door. With trembling hands, she turned the key, and the door creaked open, revealing a forgotten garden beyond.

h2: Chapter 2 – The Enchanted Realm

h3: A Magical Oasis

As Amelia stepped into the secret garden, she was immediately greeted by an explosion of colors and scents. Flowers of every hue imaginable adorned the garden, and the air was filled with the sweet melody of singing birds.

h3: Meeting the Guardian

In the center of the garden stood a majestic figure – a talking white rabbit named Oliver. He was the guardian of this enchanted realm and had been waiting for someone like Amelia to unlock the door.

“Hail, young traveler,” Oliver said, bowing politely. “Welcome to the Secret Garden. You are the chosen one, destined to bring back the magic that was lost long ago.”

Amelia was astonished but intrigued. She had always longed for a magical adventure, and now it seemed that her wish had come true.

h2: Chapter 3 – The Quest

h3: Restoring the Magic

Oliver explained that the once-thriving garden had been cursed centuries ago, causing it to wither away into oblivion. Only an outsider with a pure heart could lift the curse and restore the garden’s magic.

“I will help you on this quest,” Amelia said with determination. “Together, we shall make this garden come alive again.”

h3: Trials and Triumphs

As they journeyed through the enchanted realm, Amelia and Oliver faced many challenges. They encountered mischievous fairies, wise old tree spirits, and even a fearsome dragon guarding a precious gem needed to break the curse.

Through every trial, Amelia’s bravery and kind heart proved to be their greatest weapons. Slowly, the garden began to flourish once more, with every step they took.

h2: Chapter 4 – The Final Test

h3: Confronting the Darkness

Just as the curse was nearly broken, a dark figure emerged from the shadows. It was the sorceress who had cast the curse on the garden all those years ago. She was determined to stop Amelia and Oliver from succeeding.

h3: The Power Within

In a climactic battle, Amelia and the sorceress faced off. The sorceress used all her dark magic to defeat Amelia, but Amelia discovered an inner strength she never knew she possessed. With the love and friendship she had gained on her journey, Amelia overcame the sorceress’s darkness.

h2: Chapter 5 – The Rebirth

h3: A New Beginning

With the sorceress defeated, the curse was finally lifted from the Secret Garden. The once withered plants bloomed with life, and the entire realm sparkled with magic.

h3: A Bittersweet Farewell

As Amelia prepared to leave the enchanted realm, she felt a pang of sadness. She had grown fond of this magical oasis and all its inhabitants. Oliver, too, was saddened to bid farewell to his newfound friend.

“Do not be sad, my dear friend,” Oliver said, wiping away a tear. “Though you may leave this realm, you shall forever hold a place in our hearts.”

Amelia smiled, knowing that she would cherish the memories of her adventure forever.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.

h1: The Secret Garden

h2: Chapter 1 – The Discovery

h3: A Hidden Door

In the heart of the old mansion, young Amelia stumbled upon a mysterious, overgrown door. The mansion, a place she had inherited from a distant relative, held many secrets, but this door seemed to beckon her with an irresistible charm.

h3: The Key

After days of searching, Amelia found an old brass key that perfectly fit the lock of the hidden door. With trembling hands, she turned the key, and the door creaked open, revealing a forgotten garden beyond.

h2: Chapter 2 – The Enchanted Realm

h3: A Magical Oasis

As Amelia stepped into the secret garden, she was immediately greeted by an explosion of colors and scents. Flowers of every hue imaginable adorned the garden, and the air was filled with the sweet melody of singing birds.

h3: Meeting the Guardian

In the center of the garden stood a majestic figure – a talking white rabbit named Oliver. He was the guardian of this enchanted realm and had been waiting for someone like Amelia to unlock the door.

“Hail, young traveler,” Oliver said, bowing politely. “Welcome to the Secret Garden. You are the chosen one, destined to bring back the magic that was lost long ago.”

Amelia was astonished but intrigued. She had always longed for a magical adventure, and now it seemed that her wish had come true.

h2: Chapter 3 – The Quest

h3: Restoring the Magic

Oliver explained that the once-thriving garden had been cursed centuries ago, causing it to wither away into oblivion. Only an outsider with a pure heart could lift the curse and restore the garden’s magic.

“I will help you on this quest,” Amelia said with determination. “Together, we shall make this garden come alive again.”

h3: Trials and Triumphs

As they journeyed through the enchanted realm, Amelia and Oliver faced many challenges. They encountered mischievous fairies, wise old tree spirits, and even a fearsome dragon guarding a precious gem needed to break the curse.

Through every trial, Amelia’s bravery and kind heart proved to be their greatest weapons. Slowly, the garden began to flourish once more, with every step they took.

h2: Chapter 4 – The Final Test

h3: Confronting the Darkness

Just as the curse was nearly broken, a dark figure emerged from the shadows. It was the sorceress who had cast the curse on the garden all those years ago. She was determined to stop Amelia and Oliver from succeeding.

h3: The Power Within

In a climactic battle, Amelia and the sorceress faced off. The sorceress used all her dark magic to defeat Amelia, but Amelia discovered an inner strength she never knew she possessed. With the love and friendship she had gained on her journey, Amelia overcame the sorceress’s darkness.

h2: Chapter 5 – The Rebirth

h3: A New Beginning

With the sorceress defeated, the curse was finally lifted from the Secret Garden. The once withered plants bloomed with life, and the entire realm sparkled with magic.

h3: A Bittersweet Farewell

As Amelia prepared to leave the enchanted realm, she felt a pang of sadness. She had grown fond of this magical oasis and all its inhabitants. Oliver, too, was saddened to bid farewell to his newfound friend.

“Do not be sad, my dear friend,” Oliver said, wiping away a tear. “Though you may leave this realm, you shall forever hold a place in our hearts.”

Amelia smiled, knowing that she would cherish the memories of her adventure forever.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.

h2: Chapter 2 – The Enchanted Realm

h3: A Magical Oasis

As Amelia stepped into the secret garden, she was immediately greeted by an explosion of colors and scents. Flowers of every hue imaginable adorned the garden, and the air was filled with the sweet melody of singing birds.

h3: Meeting the Guardian

In the center of the garden stood a majestic figure – a talking white rabbit named Oliver. He was the guardian of this enchanted realm and had been waiting for someone like Amelia to unlock the door.

“Hail, young traveler,” Oliver said, bowing politely. “Welcome to the Secret Garden. You are the chosen one, destined to bring back the magic that was lost long ago.”

Amelia was astonished but intrigued. She had always longed for a magical adventure, and now it seemed that her wish had come true.

h2: Chapter 3 – The Quest

h3: Restoring the Magic

Oliver explained that the once-thriving garden had been cursed centuries ago, causing it to wither away into oblivion. Only an outsider with a pure heart could lift the curse and restore the garden’s magic.

“I will help you on this quest,” Amelia said with determination. “Together, we shall make this garden come alive again.”

h3: Trials and Triumphs

As they journeyed through the enchanted realm, Amelia and Oliver faced many challenges. They encountered mischievous fairies, wise old tree spirits, and even a fearsome dragon guarding a precious gem needed to break the curse.

Through every trial, Amelia’s bravery and kind heart proved to be their greatest weapons. Slowly, the garden began to flourish once more, with every step they took.

h2: Chapter 4 – The Final Test

h3: Confronting the Darkness

Just as the curse was nearly broken, a dark figure emerged from the shadows. It was the sorceress who had cast the curse on the garden all those years ago. She was determined to stop Amelia and Oliver from succeeding.

h3: The Power Within

In a climactic battle, Amelia and the sorceress faced off. The sorceress used all her dark magic to defeat Amelia, but Amelia discovered an inner strength she never knew she possessed. With the love and friendship she had gained on her journey, Amelia overcame the sorceress’s darkness.

h2: Chapter 5 – The Rebirth

h3: A New Beginning

With the sorceress defeated, the curse was finally lifted from the Secret Garden. The once withered plants bloomed with life, and the entire realm sparkled with magic.

h3: A Bittersweet Farewell

As Amelia prepared to leave the enchanted realm, she felt a pang of sadness. She had grown fond of this magical oasis and all its inhabitants. Oliver, too, was saddened to bid farewell to his newfound friend.

“Do not be sad, my dear friend,” Oliver said, wiping away a tear. “Though you may leave this realm, you shall forever hold a place in our hearts.”

Amelia smiled, knowing that she would cherish the memories of her adventure forever.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.

h2: Chapter 2 – The Enchanted Realm

h3: A Magical Oasis

As Amelia stepped into the secret garden, she was immediately greeted by an explosion of colors and scents. Flowers of every hue imaginable adorned the garden, and the air was filled with the sweet melody of singing birds.

h3: Meeting the Guardian

In the center of the garden stood a majestic figure – a talking white rabbit named Oliver. He was the guardian of this enchanted realm and had been waiting for someone like Amelia to unlock the door.

“Hail, young traveler,” Oliver said, bowing politely. “Welcome to the Secret Garden. You are the chosen one, destined to bring back the magic that was lost long ago.”

Amelia was astonished but intrigued. She had always longed for a magical adventure, and now it seemed that her wish had come true.

h2: Chapter 3 – The Quest

h3: Restoring the Magic

Oliver explained that the once-thriving garden had been cursed centuries ago, causing it to wither away into oblivion. Only an outsider with a pure heart could lift the curse and restore the garden’s magic.

“I will help you on this quest,” Amelia said with determination. “Together, we shall make this garden come alive again.”

h3: Trials and Triumphs

As they journeyed through the enchanted realm, Amelia and Oliver faced many challenges. They encountered mischievous fairies, wise old tree spirits, and even a fearsome dragon guarding a precious gem needed to break the curse.

Through every trial, Amelia’s bravery and kind heart proved to be their greatest weapons. Slowly, the garden began to flourish once more, with every step they took.

h2: Chapter 4 – The Final Test

h3: Confronting the Darkness

Just as the curse was nearly broken, a dark figure emerged from the shadows. It was the sorceress who had cast the curse on the garden all those years ago. She was determined to stop Amelia and Oliver from succeeding.

h3: The Power Within

In a climactic battle, Amelia and the sorceress faced off. The sorceress used all her dark magic to defeat Amelia, but Amelia discovered an inner strength she never knew she possessed. With the love and friendship she had gained on her journey, Amelia overcame the sorceress’s darkness.

h2: Chapter 5 – The Rebirth

h3: A New Beginning

With the sorceress defeated, the curse was finally lifted from the Secret Garden. The once withered plants bloomed with life, and the entire realm sparkled with magic.

h3: A Bittersweet Farewell

As Amelia prepared to leave the enchanted realm, she felt a pang of sadness. She had grown fond of this magical oasis and all its inhabitants. Oliver, too, was saddened to bid farewell to his newfound friend.

“Do not be sad, my dear friend,” Oliver said, wiping away a tear. “Though you may leave this realm, you shall forever hold a place in our hearts.”

Amelia smiled, knowing that she would cherish the memories of her adventure forever.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.

h2: Chapter 2 – The Enchanted Realm

h3: A Magical Oasis

As Amelia stepped into the secret garden, she was immediately greeted by an explosion of colors and scents. Flowers of every hue imaginable adorned the garden, and the air was filled with the sweet melody of singing birds.

h3: Meeting the Guardian

In the center of the garden stood a majestic figure – a talking white rabbit named Oliver. He was the guardian of this enchanted realm and had been waiting for someone like Amelia to unlock the door.

“Hail, young traveler,” Oliver said, bowing politely. “Welcome to the Secret Garden. You are the chosen one, destined to bring back the magic that was lost long ago.”

Amelia was astonished but intrigued. She had always longed for a magical adventure, and now it seemed that her wish had come true.

h2: Chapter 3 – The Quest

h3: Restoring the Magic

Oliver explained that the once-thriving garden had been cursed centuries ago, causing it to wither away into oblivion. Only an outsider with a pure heart could lift the curse and restore the garden’s magic.

“I will help you on this quest,” Amelia said with determination. “Together, we shall make this garden come alive again.”

h3: Trials and Triumphs

As they journeyed through the enchanted realm, Amelia and Oliver faced many challenges. They encountered mischievous fairies, wise old tree spirits, and even a fearsome dragon guarding a precious gem needed to break the curse.

Through every trial, Amelia’s bravery and kind heart proved to be their greatest weapons. Slowly, the garden began to flourish once more, with every step they took.

h2: Chapter 4 – The Final Test

h3: Confronting the Darkness

Just as the curse was nearly broken, a dark figure emerged from the shadows. It was the sorceress who had cast the curse on the garden all those years ago. She was determined to stop Amelia and Oliver from succeeding.

h3: The Power Within

In a climactic battle, Amelia and the sorceress faced off. The sorceress used all her dark magic to defeat Amelia, but Amelia discovered an inner strength she never knew she possessed. With the love and friendship she had gained on her journey, Amelia overcame the sorceress’s darkness.

h2: Chapter 5 – The Rebirth

h3: A New Beginning

With the sorceress defeated, the curse was finally lifted from the Secret Garden. The once withered plants bloomed with life, and the entire realm sparkled with magic.

h3: A Bittersweet Farewell

As Amelia prepared to leave the enchanted realm, she felt a pang of sadness. She had grown fond of this magical oasis and all its inhabitants. Oliver, too, was saddened to bid farewell to his newfound friend.

“Do not be sad, my dear friend,” Oliver said, wiping away a tear. “Though you may leave this realm, you shall forever hold a place in our hearts.”

Amelia smiled, knowing that she would cherish the memories of her adventure forever.

h1: Epilogue

In the years that followed, Amelia visited the Secret Garden whenever she could. The magical realm became a bridge between the ordinary world and a realm of wonder, reminding her that magic could be found in the most unexpected places.

And so, the Secret Garden thrived with the love and care of its guardian, Oliver, and its protector, Amelia.