**SD-01 WebUI 安裝的相關網址** ![qr.ioi.tw](https://hackmd.io/_uploads/HyIDrVONp.png) **開始進行 SD WebUI 安裝前的個人電腦硬體環境檢核** 1. 檢查硬碟容量(儲存空間),建議大小最少 80GB 1. 在裝置管理員視窗中的「顯示卡」檢查顯示卡的驅動程式版本,建議不應該晚於三個月,否則請更新 Nvidia 顯示卡驅動程式下載網站,依照顯示卡版本與作業系統下載相對應驅動程式後更新。 https://www.nvidia.com/zh-tw/drivers/ **WebUI本機安裝(SDlocal)** 先在D槽建立新資料夾 取名SDlocal之後所有程式及模型皆放置此資料夾 Automatic Installation on Windows https://github.com/AUTOMATIC1111 https://github.com/AUTOMATIC1111/stable-diffusion-webui 安裝的四個步驟 ![螢幕擷取畫面 2024-02-23 095109](https://hackmd.io/_uploads/rJur5uH26.png) windows PowerShell 或右鍵按下Window圖標打CMD ![螢幕擷取畫面 2024-02-29 145005](https://hackmd.io/_uploads/ryauYjT2a.png) ![螢幕擷取畫面 2024-02-29 145022](https://hackmd.io/_uploads/S1YttjTna.png) 先檢查本機是否已安裝Python & Git及版本? python --version git --version ![螢幕擷取畫面 2024-02-26 090012](https://hackmd.io/_uploads/rJqlXwYna.png) "Automatic Installation on Windows" Install Python 3.10.6 https://www.python.org/downloads/release/python-3106/ Install git https://git-scm.com/download/win **Nvidia顯卡用戶輸入以下指令** git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git AMD顯卡用戶請用這個DirectML的分支: https://github.com/lshqqytiger/stable-diffusion-webui-directml git clone https://github.com/lshqqytiger/stable-diffusion-webui-directml.git Intel Arc顯卡用戶請用這個DirectML的分支: git clone https://github.com/Aloereed/stable-diffusion-webui-arc-directml.git **開啟SD方式 雙擊(webui-user.bat)檔** ![螢幕擷取畫面 2024-02-23 092119](https://hackmd.io/_uploads/r1yxEOrna.png) ![螢幕擷取畫面 2024-02-14 091154](https://hackmd.io/_uploads/rkQyEqKia.png) 在使用SD期間 此畫面不能關閉 ![螢幕擷取畫面 2024-02-14 091138](https://hackmd.io/_uploads/BJjXV9Kjp.png) 要離開SD時 在DOS下同時按下Ctrl+C後 會出現:要終止批次工作嗎?按下Y後 再關閉SD **安裝主程式後的預設畫面** ![螢幕擷取畫面 2024-02-14 084945](https://hackmd.io/_uploads/SkzSAFKip.png) theme dark(操作介面改為黑色)並修改一些指令設定後 ![螢幕擷取畫面 2024-02-14 084926](https://hackmd.io/_uploads/SJYrAFYsp.png) **安裝 --xFormers及深色介面** COMMANDLINE_ARGS=--xformers --theme dark 使用xFormers進行推理和訓練。在測試中,在註意力區塊中執行的最佳化可以提高速度並減少記憶體消耗。 ![image](https://hackmd.io/_uploads/ByU-BOZi0.png) ![螢幕擷取畫面 2024-08-20 100753](https://hackmd.io/_uploads/SJaq9dWo0.png) 編輯修改webui-user.bat 檔案中的 set COMMANDLINE_ARGS=--theme dark 操作介面就會變成深色底 ![螢幕擷取畫面 2024-02-23 095503](https://hackmd.io/_uploads/H10Zi_S3a.png) **Extensions連接網址** https://github.com/benlisquare/stable-diffusion-webui-localization-zh_TW.git (中文) https://github.com/journey-ad/sd-webui-bilingual-localization.git (雙語對照) https://github.com/Mikubill/sd-webui-controlnet.git (ControlNet) https://github.com/Physton/sd-webui-prompt-all-in-one (提示詞) https://github.com/Coyote-A/ultimate-upscale-for-automatic1111.git (放大) https://github.com/butaixianran/Stable-Diffusion-Webui-Civitai-Helper.git (civitai Helper) https://github.com/a2569875/lora-prompt-tool.git (LoRA 模型提示) https://github.com/richrobber2/canvas-zoom.git (畫布) https://github.com/daxijiu/sd-webui-sdxl-styles-preset.git (style) https://github.com/deepinsight/insightface.git (insightface) **最基本的參數修改** COMMANDLINE_ARGS=--xformers --theme dark **不同規格電腦 所需不同的優化 參數說明** 無GPU COMMANDLINE_ARGS=--skip-torch-cuda-test --no-half --no-half-vae COMMANDLINE_ARGS =--opt-sub-quad-attention --no-half --precision full --lowvram 顯示卡的 vram >= 8,則不需要加上 --lowvram 或 --medvram (即空著) 顯示卡的 vram = 6GB 則設成 --medvram, 顯示卡的 vram < 6GB 則設成 --lowvram --no-half(不使用半精度運算模型) --no-half-vae(不使用半精度運算VAE) --xformers(可進一步減少VRAM佔用,只支援Nvidia顯示卡) --theme dark(操作介面改為黑色) 空白 : 是告訢 SD 我的電腦中有足夠多的 vram,可以用全力去跑運算。(所以應該是會在最快的時間完成運算) --medvram : 告訢 SD 我的電腦中只有中度容量的 vram。(會是次快時間完成運算) --lowvram : 告訢 SD 我的電腦中只有低度容量的 vram。(要用最節省資源的方式去執行運算,所以會是這三個中最慢完成運算) 當然這三者一定都還是比只用CPU (沒有GPU)的還快! set COMMANDLINE_ARGS參數說明: --listen:讓區域網路中的別台電腦可以連入並操作 --share:產生時效為72小時的網址,讓外部電腦可以連入並操作 --enable-insecure-extension-access:執行不安全延伸程式 **模型及提詞參考網站** safetensors 文件是什麼? safetensors 文件是模型文件,是 Hugging Face 公司推出的一種用于保存模型的新文件格式,它旨在解决模型加载和使用中的安全問題。 https://www.youtube.com/watch?v=jaFuhJZPJ5c (老阿貝-extensions詳細說明包含關閉和開啟,備份、刪除、回復,更新) https://civitai.com/?tag=buildings (civitai模型下載網站) https://prompthero.com/search?q=building (PromptHero提詞參考網站) https://prompthero.com/search?q=interior (interior 提詞參考網站) https://stable-diffusion-art.com/sdxl-styles/ (106 styles for Stable Diffusion XL model) **WebUI操作步驟** 原始英文介面 要安裝extension後才會有中英文介面 1. 操作步驟-以文生圖 加上設計底圖操作為例 ![step01](https://hackmd.io/_uploads/BJpSNkdNyg.jpg) 1. 選取chickpoint&vae modle ![step02-chickpoint&vae](https://hackmd.io/_uploads/SJDAQydNkg.jpg) 1. 填入正反向提示詞 ![step03-prompts](https://hackmd.io/_uploads/SyfJVydEkl.jpg) 1. 相關生成參數設定 ![step04-generation](https://hackmd.io/_uploads/HJ1ZE1u4ye.jpg) 1. 啟動生成 及 AI圖片資訊 ![step06-generate & data](https://hackmd.io/_uploads/SJfm41u4yx.jpg) **WebUI官網案例 文生圖練習** Prompt 1:green sapling rowing out of ground,mud,dirt,grass,high quality,photorealistic,sharp focus,depth of field Negative Prompt:ugly,blurry,low quality, Prompt 2:masterpiece,best quality,high detailed,8k uhd,high quality,film grain,soft lighting, checkpoint model:v1-5-pruned-emaonly.safetensors Steps: 20, Sampler: Euler a, CFG scale: 7, Size: 512x512, ![螢幕擷取畫面 2024-02-23 114927](https://hackmd.io/_uploads/B1DdIcrn6.png) ![螢幕擷取畫面 2024-02-23 114755](https://hackmd.io/_uploads/S1lFrcBnp.png) **"請像建築大師那樣 描述這張立面圖的細節 並簡化為SD Prompts"** **使用ChatGPT生成提示詞** 底圖1 ![ComfyUI_14260_](https://hackmd.io/_uploads/HkFf0cYqC.png) ![image](https://hackmd.io/_uploads/SkBYxbXcC.png) ![image](https://hackmd.io/_uploads/r18ceWXq0.png) Prompt:A tall,modern residential building with a minimalist geometric design, featuring vertical dark stripes that emphasize its height. The facade consists of uniformly arranged square windows, some with balconies with glass railings. The ground floor is transparent with large glass panels, suggesting communal or commercial spaces. The main materials are white concrete or plaster and contrasting dark metal or wood for the vertical accents. The overall style is clean and contemporary, with a strong vertical emphasis (一棟高大的現代住宅大樓,採用簡約的幾何設計,以垂直的深色條紋強調其高度。立面由均勻排列的方形窗戶組成,部分窗戶設有帶玻璃欄桿的陽台。底層是透明的,有大玻璃板,暗示著公共或商業空間。主要材料是白色混凝土或石膏,以及對比鮮明的深色金屬或木材作為垂直裝飾。整體風格乾淨、現代,強調垂直方向) Negative Prompt:ugly,blurry,low quality, **文生圖練習** ![image](https://hackmd.io/_uploads/rJ9BFTFqC.png) ![00085-2133417465](https://hackmd.io/_uploads/HJew6uTY5A.jpg) ![00009-2398247508](https://hackmd.io/_uploads/rknhR8JjC.jpg) **主程式更新** 在資料夾路徑上 CMD到windows中 執行git pull(小寫) ![螢幕擷取畫面 2024-01-11 092816](https://hackmd.io/_uploads/ryfvVa2Op.png) **Extension更新** 在Extension頁面下執行 ![螢幕擷取畫面 2024-01-11 092507](https://hackmd.io/_uploads/Hk2-4anOp.png) **版本更新 若出現錯誤訊息** ![image](https://hackmd.io/_uploads/rklmky0JJg.png) 可以把venv資料夾刪除 在執行.bat檔 會再重新安裝相關環境配置依賴包 如果你是手動安裝官方的webui,運行bat後,會幫你安裝依賴,依賴安裝完啟動,會創建一個venv資料夾,他是python為了不影響系統整個python的環境,虛擬出一個沙箱環境,用來放置專門為這個專案安裝的一些庫。 遷移了資料夾,這個虛擬環境的路徑不對了,所以運行不了。我們只需要修改虛擬環境的路徑就可以了。webui目錄下venv/scripts/activate.bat 修改為你遷移後目錄的路徑。 這裡需要理解venv虛擬環境這個概念,如果你用的是懶人包(一鍵安裝包)他是獨立的python環境,也不會創建venv虛擬環境資料夾。不在這個問題討論範圍。 作法:更新指令完成後 先將檔案中的 venv檔案刪除 重新雙擊開啟webui-user.bat檔 會重新安裝venv中 所有的程式依賴檔案 完全下載後(需要時間) 就會開啟操作介面 檢查最下方的資訊欄 ![螢幕擷取畫面 2024-03-21 140048](https://hackmd.io/_uploads/r1V7aSY0p.png)