LoginSignup
1
1

More than 1 year has passed since last update.

Stable Diffusion web UIの旧バージョンをGoogleColaboratoryで起動する

Last updated at Posted at 2023-05-14

色々忙しくて、久々の更新になります

Stable Diffusion web UIをGoogleColaboratoryで起動しようと思ったのですが
RuntimeErrorで起動できません

Stable Diffusion web UIがかなりの頻度で更新されているため
どうしても旧来の手順では上手く起動できないようです

かなり手間は掛かるのですが
旧バージョンのStable Diffusion web UIを使用するしかないようです
(悠様参考)

まず、旧安定版のStable Diffusion web UIにアクセスします

緑色の[Code]→[Download ZIP]でローカルにZIPファイルでDownloadします
Downloadが終わったら解凍します

解凍が終わったら
GoogleColaboratoryを使用しているアカウントで
Googleドライブにアクセスします

そして、「マイドライブ」以下のどこかに
ディレクトリ(私は「StableDiffusion」としました)を作成し
その中に解凍した旧安定版のStable Diffusion web UIをアップロードします

自分は、以下のようにしました
setting_20230515_02.png

終わったら、GoogleColaboratoryで
新規ノートブックを作成します(GPUの設定を忘れずに)

作成が終わったら
左のツールバーから
「ファイル」→「ドライブをマウント」を行い
先程、Googleドライブにアップロードしたファイルが表示されていることを確認します

ここでColaboratoryのセルに次のようなコードを入力し実行します
(folder_1のパスは各自のものに合わせて下さい)

#旧versionのWebUIを複製
import shutil

folder_1 = '/content/drive/MyDrive/StableDiffusion/stable-diffusion-webui-a9fed7c364061ae6efb37f797b6b522cb3cf7aa2'
folder_2 = '/content/stable-diffusion-webui'
shutil.copytree(folder_1 , folder_2)

%cd /content/stable-diffusion-webui

#LoRAモデルを格納するフォルダを作成
!mkdir -p /content/stable-diffusion-webui/models/Lora

#Hypernetworkを格納するフォルダを作成
!mkdir -p /content/stable-diffusion-webui/models/hypernetworks

setting_20230515_01.png

ここまで終わったら
以前まで使用していたコードでStable Diffusion web UIをインストールしていきます

!wget https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5.safetensors -O /content/stable-diffusion-webui/models/Stable-diffusion/Counterfeit-V2.5.safetensors
!wget https://huggingface.co/gsdf/Counterfeit-V2.5/resolve/main/Counterfeit-V2.5.vae.pt -O /content/stable-diffusion-webui/models/VAE/Counterfeit-V2.5.vae.pt

%cd /content/stable-diffusion-webui/extensions/
!git clone https://github.com/liasece/sd-webui-train-tools /content/stable-diffusion-webui/extensions/sd-webui-train-tools

%cd /content/stable-diffusion-webui
!pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchtext==0.14.1 torchaudio==0.13.1 torchdata==0.5.1 --extra-index-url https://download.pytorch.org/whl/cu117
!python launch.py --share --xformers --enable-insecure-extension-access

これで起動できます

ちなみにですが
以前まで必要だったPythonのバージョンアップは不要になりました
(GoogleColaboratoryのPythonのデフォルトバージョンが3.10.11となったため)

以上です
また、ぼちぼちStable Diffusion関連の記事を投稿していく予定です

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1