輕鬆安裝Stable Diffusion WebUI到Google colab

1.打開Google Colab網站,左上角檔案→點擊新增筆記本。

2.複製以下內容粘貼到筆記本。

from google.colab import drive
drive.mount('/content/drive')
!mkdir /content/drive/MyDrive/sd-webui-files
!pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
!pip install -q xformers==0.0.16
!pip install -q triton==2.0.0
!git clone --depth=1 https://github.com/AUTOMATIC1111/stable-diffusion-webui.git /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui
!wget -nc -P /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/models/Stable-diffusion https://huggingface.co/andite/anything-v4.0/resolve/main/anything-v4.5-pruned.safetensors
!wget -nc -P /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/models/Lora https://civitai.com/api/download/models/13739 -O Korean_Doll_Likenesss.safetensors
!git clone --depth=1 https://github.com/benlisquare/stable-diffusion-webui-localization-zh_TW.git /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/extensions/stable-diffusion-webui-localization-zh_TW
!git clone --depth=1 https://github.com/Mikubill/sd-webui-controlnet.git /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/extensions/sd-webui-controlnet
!wget -nc -P /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/extensions/sd-webui-controlnet/models https://huggingface.co/lllyasviel/ControlNet/resolve/main/models/control_sd15_scribble.pth
%cd /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/
!git reset --hard
!git pull
!sed -i -e 's/checkout {commithash}/checkout --force {commithash}/g' launch.py
!python launch.py --share --xformers --enable-insecure-extension-access --theme light

3.按上面的執行階段 → 變更執行階段,把硬體加速器的選項從 None改成GPU(改成GPU後會多出GPU 類型T4,不用理  ),直接點右下方的儲存。

4.點選左上角的圓形三角符號執行儲存格,然後按連線至雲端硬碟並允許存取雲端硬碟。

5.然後就慢慢等它跑完,最後會出現一個public url,然後點進去就是你的stable diffusion webUI了。

6.用完後就按上面的執行階段 → 中斷並刪除執行階段。因為相關文件都是存在雲端,關閉後也不會被刪除。

7.完成安裝後就可以將筆記本的内容替換為以下程式碼。下次開就能直接啟動WebUI而不用再等它跑安裝了。

from google.colab import drive
drive.mount('/content/drive')
!pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116 -U
!pip install -q xformers==0.0.16
!pip install -q triton==2.0.0
%cd /content/drive/MyDrive/sd-webui-files/stable-diffusion-webui/
!python launch.py --share --xformers --enable-insecure-extension-access --theme light

下面是幾個比較常用的資料夾:
(這些檔案都能在你的雲端硬碟的sd-webui-files的stable-diffusion-webui下找到)
extensions:是用來放擴充功能的位置。
models/stable-duffusion:是放模型的位置。
models/Lora:是放Lora的位置。
outputs:你生成的圖片自動保存的位置。

來源

Share this content:

ai 一 鍵 去 衣 app (1) AI繪圖 (15) chat (36) ChatGPT代替 (2) ChatGPT替代 (22) ChatGPT替代品 (7) ChatGPT替代替代品 (14) GPT4 (6) 免費使用 (32) 寫作 (1) 影片製作 (1) 搜尋引擎 (2) 文本生成影片 (1) 有限免費 (9) 編程 (1) 繪圖 (12) 繪圖工具 (12) 繪畫 (1) 自動 (1) 自動化 (1)

There are no reviews yet. Be the first one to write one.