Try   HackMD

AI 生圖 Stable Diffusion web UI 筆記

Stable Diffusion web UI 安裝篇

系統需求

我是在 Windows 11 的環境下使用的,沒有外接顯示卡,使用 CPU 內顯
CPU 是 AMD Ryzen™ 7 PRO 4750G
內顯的 vram 4GB
記憶體是2條16GB 3200 MHz

硬碟建議預留30GB以上空間 (安裝一種模型可能就 7~8 GB了)


安裝步驟

  • 安裝 Python 3.10
    從 Microsoft Store (Microsoft市集) 直接下載安裝,用這個的原因是會設定 PATH 路徑 的系統變數

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 安裝 Git
    版本控制的東西,從 git for windows 的網站下載安裝,安裝過程都是選預設的即可
    https://gitforwindows.org/

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • 指令列安裝 Stable Diffusion web UI,共四個指令

先到要安裝的路徑,在資料夾空白處按右鍵在終端中開啟(cmd) 或是 powershell ,啟動指令列視窗,依序輸入下列的指令,這些指令分別是

  1. git 指令是從 github 網站上將主程式複製一份到自己電腦目前位置
  2. 進入主程式資料夾
  3. 啟動子模組
  4. 更新子模處
git clone https://github.com/lshqqytiger/stable-diffusion-webui-directml

cd stable-diffusion-webui-directml

git submodule init

git submodule update

安裝完後,到資料夾開啟 webui.bat
第一次執行會很長,執行畫面長這樣

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


其他具體安裝東西參考官方 github 說明
https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs

因為我是用內顯算圖,所以記憶體比較缺乏,需要手動用記事本開啟開啟 webui-user.bat 這個檔案並進行修改,將原本的
set COMMANDLINE_ARGS= 後面追加一些指令,降低效能但可以讓運作正常,這些是我加的

set COMMANDLINE_ARGS=--opt-sub-quad-attention --lowvram --precision full --no-half  --disable-nan-check --autolaunch

AI算圖中的樣子

command line 視窗不要關 (可以縮到背景)

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


AMD 效能監控畫面

VRAM一定是全滿,分出去共享的RAM也不少

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


故障的情形

終端視窗最後一行會顯示 Runtime Error

通常是數值調太高(寬高太高 steps 太多、批次數量太多),就有可能會故障,這時候改低一些,重新生成就好

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


使用的情形或問題

  • 內顯算一張 512x512,steps 20 的大概要150秒(2分半)

  • 如果算出來圖都是全黑,試試看更新顯示卡驅動,我更新到最新的才正常

  • 有時候亂數種子算出來就是會出現一些會降低 san 值的東西,換一組種子就好,建議一次至少4張去算,失敗幾張就算了

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →


下載模型的地方

看圖的地方?

  • MajinAI(まじない) 分享AI繪圖的網站,介面有繁體中文。
    https://majinai.art/

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • PixAI.Art 可以直接看圖也能線上算圖
    https://pixai.art/

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →


沒有電腦可以算圖又想玩? 試試看其他線上服務吧

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

  • pixai 每天有免費 credit 可以領,用 credit 產圖比較快,不使用的畫一張圖大概要等快2天
    https://pixai.art/

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

  • Dall-E2 預先註冊,等拿到帳號就有免費額度可以用,每個月刷新可用額度
    https://openai.com/product/dall-e-2

  • midjourney 用 discord 註冊帳號有免費幾張圖可以用,後面就沒了,圖看起來很繪本風

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

img2img

關鍵點