画像生成AIの情報を纏めるWikiです。

学習は別のでやる流れだけど生成には便利に使えるはず。

Remote UI(1111を含む)の利用が禁止になりました。
以後、ブラウザで操作するタイプのソフトウェアは使わないでください。



最新版はこちら


今後の更新はありません。

最終版のセル(参考)
#@title ↓再生ボタンを押してね

#@markdown 実行は自己責任で。

#@markdown gradioログイン情報(パスワード空白時は自動生成)
user = "user"#@param {type:"string"}
password = ""#@param {type:"string"}



#@markdown 環境調査(2回目以降は飛ばしてもいい)
use_envcheck = True #@param {type:"boolean"}
if use_envcheck:
  # Ubuntu
  !uname -m && cat /etc/*release
  res = !cat /etc/*release | grep 'VERSION_ID' | grep -o '[0-9.]*'
  if not res[0].startswith('20.04'):
    raise RuntimeError("Ubuntuのバージョンが変わった " + res[0])

  # Python
  res = !python -V | grep -o '[0-9.]*'
  if not res[0].startswith('3.9.'):
    raise RuntimeError("Pythonのバージョンが変わった " + res[0])

  # GPU/CUDA
  !nvidia-smi
  res = !nvcc -V | grep 'Cuda compilation tools, release' | grep -o '[0-9.]*'
  if not res[0].startswith('11.8'):
    raise RuntimeError("CUDAのバージョンが変わった " + res[0])

  # RAMの容量取得(GiB)
  res = !free -m | grep 'Mem:' | awk '{print $2}'
  if not res:
    raise ValueError("RAMが取得できない")
  ram = round(float(res[0]) / 1024, 3)
  if ram < 12:
    raise ValueError("RAMが思ったより少ない" + ram)
  print(f"RAM : {ram}")

  # VRAMの容量取得(GiB)
  res = !nvidia-smi --query-gpu=memory.total --format=csv,noheader,nounits
  if not res:
    raise ValueError("VRAMが取得できない(GPUに繋がってないかも)")
  vram = round(float(res[0]) / 1024, 3)
  if vram < 14:
    raise ValueError("VRAMが思ったより少ない " + vram)
  print(f"VRAM: {vram}")
  del res

### セットアップ

%cd /content

#@markdown # Pythonインストール

#@markdown miniconda 3.10.9
use_conda = False #@param {type:"boolean"}
#@markdown apt-get 3.10.10 こっちは最近調子悪いみたい
use_apt = False #@param {type:"boolean"}

if use_conda and use_apt:
   raise ValueError("どっちやねん")

if use_conda:
   !wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
   !bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local

if use_apt:
  !sudo apt autoremove
  !sudo apt-get -y update
  !sudo apt-get -y install python3.10
  !sudo cp `which python3.10` /usr/local/bin/python

# Pythonのバージョン確認
!python -V

# pipを最新に
!wget https://bootstrap.pypa.io/get-pip.py -O - | sudo python

#@markdown xformersインストール(当面torch1のみ)
use_xformers = False #@param {type:"boolean"}

#@markdown torch2インストール(use_conda必須)
use_torch2 = False #@param {type:"boolean"}
if use_torch2:
  !pip install --upgrade torch torchvision --extra-index-url https://download.pytorch.org/whl/cu118
# torch1をアップデート(Python 3.10の時だけ)
elif use_conda or use_apt:
  !pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117

if use_xformers:
  !pip install -U --pre triton
  !pip install xformers==0.0.16rc425

# これが無いと動かないので
!pip install fastapi==0.90.1

### パスワード関連

# デフォルトパスワード生成
import secrets
import string

def get_password(length: int) -> str:
    # secretsはrandomとかと違って暗号学的に安全な乱数を生成できる。
    pass_chars = string.ascii_letters + string.digits
    password = ''.join(secrets.choice(pass_chars) for i in range(length))
    return password

if not password:
    password = get_password(64)

del secrets
del string
del get_password

### WEBUIのセットアップ

%cd /content/
!git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
%cd stable-diffusion-webui/models/Stable-diffusion

#@markdown モデルのURL(複数いるならFilerでダウンロードしましょう)
ckpt_url = 'https://huggingface.co/aka7774/fp16_safetensors/resolve/main/7th_anime_v3_A-fp16-1833-2982-0018.safetensors'#@param {type:"string"}
# ダウンロードにトークンの要らないモデルなのでコメントアウト
##@markdown トークンはここで貰ってきて https://huggingface.co/settings/tokens
#user_token = ''#@param {type:"string"}
#user_header = f"\"Authorization: Bearer {user_token}\""
#!wget -c --header={user_header} "{ckpt_url}" -P /content/stable-diffusion-webui/models/Stable-diffusion/
#del user_header
if ckpt_url:
   !wget -c "{ckpt_url}" -P /content/stable-diffusion-webui/models/Stable-diffusion/

# @markdown aria2cで落としたいモデルのURL(なければ空白)
aria_url = ''#@param {type:"string"}
if aria_url:
    !apt install -y -qq aria2
    !aria2c --summary-interval=10 -x 3 --allow-overwrite=true -Z {aria_url}

import os

#@markdown # Extensions
%cd /content/stable-diffusion-webui/extensions/

#@markdown --enable-insecure-extension-access
use_eiea = False #@param {type:"boolean"}

#@markdown ImagesとFilerはColabで便利なので入れましょう
use_filer = True #@param {type:"boolean"}
if use_filer:
    #!git clone https://github.com/aka7774/sd_images_browser.git
    !git clone https://github.com/AlUlkesh/stable-diffusion-webui-images-browser.git
    !git clone https://github.com/aka7774/sd_filer.git

#@markdown 型抜き系(Katanuki rembg PBRemTools)
use_katanuki = False #@param {type:"boolean"}
if use_katanuki:
    !git clone https://github.com/mattyamonaca/PBRemTools.git
    !git clone https://github.com/aka7774/sd_katanuki.git
    !git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui-rembg.git

#@markdown 学習関連(dreambooth, Hypernetwork-MonkeyPatch)
use_train = False #@param {type:"boolean"}
if use_train:
    !git clone https://github.com/d8ahazard/sd_dreambooth_extension.git
    !git clone https://github.com/aria1th/Hypernetwork-MonkeyPatch-Extension.git

#@markdown マージ関連(supermerger, MBW)とモデル変換(toolkit)
use_merge = False #@param {type:"boolean"}
if use_merge:
    !git clone https://github.com/hako-mikan/sd-webui-supermerger.git
    !git clone https://github.com/bbc-mc/sdweb-merge-block-weighted-gui.git
    !git clone https://github.com/aka7774/sd_merge_numa.git
    !git clone https://github.com/arenatemp/stable-diffusion-webui-model-toolkit.git

#@markdown LoRA関連(additional-networks, locon, two-shot)
use_lora = False #@param {type:"boolean"}
if use_lora:
    !git clone https://github.com/kohya-ss/sd-webui-additional-networks.git
    !git clone https://github.com/KohakuBlueleaf/a1111-sd-webui-locon.git
    !git clone https://github.com/opparco/stable-diffusion-webui-two-shot.git

#@markdown ControlNet(fp16モデルつき)
use_controlnet = False #@param {type:"boolean"}
if use_controlnet:
  !pip install prettytable
  !git clone https://github.com/Mikubill/sd-webui-controlnet.git
  %cd sd-webui-controlnet
  !git clone https://huggingface.co/webui/ControlNet-modules-safetensors.git
  for fi in os.listdir("ControlNet-modules-safetensors"):
    os.rename(f"ControlNet-modules-safetensors/{fi}", f"models/{fi}")
  %cd ..
  !git clone https://github.com/gogodr/sd-webui-stopmotion.git

#@markdown aka: fake_xyplot, curly_rand, copyguard
use_aka = False #@param {type:"boolean"}
if use_aka:
    !git clone https://github.com/aka7774/sd_fake_xyplot.git
    !git clone https://github.com/aka7774/sd_curly_rand.git
    !git clone https://github.com/aka7774/sd_copyguard.git

#@markdown aka: Gimai(ゲームの会話シーン制作)
use_gimai = False #@param {type:"boolean"}
if use_gimai:
  !sudo apt install ffmpeg
  !ffmpeg -version
  !git clone https://github.com/aka7774/sd_gimai.git
  %cd sd_gimai
  !git clone https://huggingface.co/spaces/skytnt/moe-tts.git
  %cd ..

# 一度起動して必要なものをインストールする
%cd /content/stable-diffusion-webui/
!COMMANDLINE_ARGS="--exit" REQS_FILE="requirements.txt" python launch.py

#@markdown ## Google Driveのマウント(任意)
use_drive = False #@param {type:"boolean"}
if use_drive:
  from google.colab import drive
  drive.mount('/content/drive')
  # filerのデフォルトバックアップ先を設定
  !mkdir -m 0777 /content/stable-diffusion-webui/extensions/sd_filer/config
  !echo '{"backup_dir":"/content/drive/MyDrive/sd"}' > /content/stable-diffusion-webui/extensions/sd_filer/config/config.json

# WEBUIの起動
!COMMANDLINE_ARGS="{'--xformers' if use_xformers else ''} {'--opt-sdp-no-mem-attention' if use_torch2 else ''} --opt-channelslast {'--enable-insecure-extension-access' if use_eiea else ''} --share --gradio-auth {user}:{password}" REQS_FILE="requirements.txt" python launch.py

更新について


pipの問題で動かなくなりがちなのでコメント等を見るといいかも。

更新履歴

2023-04-05
  • 本体の動作確認できてないんだけど、気になったExtensionを追加した。
    • PBRemTools AlUlkesh/stable-diffusion-webui-images-browser sd-webui-stopmotion
2023-03-19
  • torch2に対応しました。めちゃ速くなるので楽しい。
  • xformersを入れなくできるようにした(torch2では不要だし)
  • 環境調査をスキップできるようにした
  • Extensionsを更新(LyCoris動かす用など)
  • --enable-insecure-extension-accessを入れられるようにした
2023-03-16
  • Pythonのバージョン指定を次の3つに変更しました
    • Python 3.9.16 Colabデフォルト 時短になるのでおすすめ
    • Python 3.10.9 use_conda 最新版を入れるので将来おかしくなる可能性あり 今3.9だと困る場合にどうぞ
    • Python 3.10.10 use_apt 従来通り。今はうまく動いていない?
  • Python 3.9.16選択時にはデフォルトのtorchを使うようにしました 時短
  • 環境チェックを厳格にしてRuntimeErrorを返すようにしました
2023-02-15
  • ControlNet(fp16)に対応しました
  • 学習はkohya_train_network_simpleで出来るのでExtensionを外しました
  • fastapiのバージョンを0.90.1に固定しました
  • Pythonが3.10.10になってました(悪影響は無いはず)

segがエラーで動かんなあ。prettytableは入れたつもりなんだけど。
ModuleNotFoundError: No module named 'lib2to3'
2023-01-24
  • Python 3.10にきちんと対応(xformersがすんなり入るよ、やったね)
  • モジュールのバージョンをあげました
  • 流行りのExtensionsに入れ替え(面倒なので今後はやらんかも)
  • モデルのURLをVAE内蔵の7th3Aにしました(ダウンロードが早く済むはず)
2023-01-14
  • images_browserを修正版に取り替えた
  • その他こまごまとExtensions追加
2022-12-20
  • condaかpipか選べるようにした。エラー出た時の予備になるかも?
  • 階層マージ遊びが出来るExtensionをインストールできるようにした(たぶん4GBのモデルならいける)
  • モデルのURLを3つまで入れられるようにした(もっと入れたければ改造して)
  • SD2.0系は未対応(需要あれば対応する)

初心者向け手順

  1. Googleアカウントを用意する(普段使いとは分けるのがおすすめ)
  2. 次のページを読んで基礎を理解する
    1. https://www.python.jp/train/experience/colab.html
    2. https://www.python.jp/train/experience/exec-python...
  3. 「1+1」のかわりに 以下の黄色い枠内の内容をコピペして 上のリンク先のnotebook内容をコピーして実行
  4. 実行結果に「Running on public URL: https://xxxxx.gradio.live」と出てくるのでそこに飛んで、usernameとpasswordを入力する
    1. usernameはデフォルト実行ならuser。passwordは自動生成されているので「Launching Web UI with arguments:」の行を参照

注意

Notebookを新規作成できたら、最初に Rumtime - Change runtime type で GPU を選ぶ

もう最初っから選ばれてるかも。


このNotebookではいくつかのExtensionが自動インストールされる
  • 重たいやつはチェックボックスで入れるかどうか選べる
モデルを増やしたい時はFilerでダウンロードしよう

ダウンロードしたいモデルのURLを用意しましょう


Google Driveのマウントはしなくても動かせるのでお好みで
  • マウントしないと全部消えるので後腐れが無い
  • マウントするとデータの保存が楽になる

赤ちゃん用Notebook

グラボもねえ!知識もねえ!金もそれほど持ってねえ!
でもローカル使ってみたいンゴ・・・!という人でも使える(かもしれない)Notebookが公開されている
上記の入門用Notebookですらうまくいかなかった人用
※高頻度で更新されているので、このページの説明と違う箇所もあるかもしれない

入門用Notebook(旧バージョン)


このページへのコメント

無料版のSD禁止令どうしようか…

0
Posted by 名無し(ID:DP94BRcwcg) 2023年04月21日(金) 19:06:41 返信数(1) 返信

今までの無料の利用頻度(一日2時間程度)なら有料プランでも約50時間で25日は使えるし、課金したらいいんじゃない?
月1000円ちょっとで今まで通り遊べるなら十分安い趣味だと思うけど
クレカなければVISAデビットでも作ればいいし

0
Posted by 名無し(ID:mmBfhLpayw) 2023年04月21日(金) 23:58:05

VAEの追加ってどうしたらええんや?

0
Posted by 名無し(ID:x+Xh7RuWRw) 2023年03月19日(日) 23:32:49 返信数(2) 返信

Filerでダウンロードしたり、
aria_urlでもいけると思うけど、
1モデルを使いこむのが主なら、
ベストは事前にマージしたモデルを🤗にあげといて、
それをckpt_urlで入れちゃうことかな

1
Posted by 名無し(ID:DqSiI5hXpw) 2023年03月20日(月) 06:15:38

なるほどーサンガツや!

0
Posted by 名無し(ID:x+Xh7RuWRw) 2023年03月20日(月) 21:47:05

error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Preparing metadata (setup.py) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

これ出るようになって起動出来なくなったね
gdrive通してなくても出るし書いてある通りパッケージの問題?

4
Posted by 名無し(ID:DP94BRcwcg) 2023年03月15日(水) 09:55:29 返信数(3) 返信

他の人のノートブックは普通に動くんで原因分かるまでそれ使うといいすね

エラー試行錯誤とか色々グチャグチャになってもいいならwikiノートブックのPython関係のとこ消して他のノートブックから拝借したコード継ぎ接ぎとかすれば一応動きます

0
Posted by 名無し(ID:DP94BRcwcg) 2023年03月15日(水) 20:32:11

Python関連の更新があったらしいです
minicondaを入れると動きました

具体的には

# バージョンあがってないかな
!uname -m && cat /etc/*release | head -n 2
!python -V
---ここから---
!wget ://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local
---ここまで---
h t t p sを入力禁止にされたのでwegtの後に入れてください

3
Posted by 名無し(ID:F11fIIjbFg) 2023年03月15日(水) 21:19:43

動きますね。
とりあえずそちらのコード加えてこれは一時解決かな

0
Posted by 名無し(ID:DP94BRcwcg) 2023年03月15日(水) 22:53:21

Driveに保存してるモデルを使いたいですので「モデルのURL」のところに /content/drive/MyDrive/Counterfeit-V2.5.safetensors と入れましたがダメでした。どうすればDriveのファイルが使えますか?

エラーメッセージ:
Can't run without a checkpoint. Find and place a .ckpt or .safetensors file into any of those locations. The program will exit.

0
Posted by 名無し(ID:muO4hreMWg) 2023年02月16日(木) 18:17:32 返信数(2) 返信

起動時に--ckptで指定するか、
!cp /content/drive/MyDrive/Counterfeit-V2.5.safetensors /content/stable-diffusion-webui/models/Stable-diffusion/
でいけるんでないかな

0
Posted by 名無し(ID:DqSiI5hXpw) 2023年02月16日(木) 19:04:10

ありがとうございました

0
Posted by 名無し(ID:muO4hreMWg) 2023年02月16日(木) 23:59:38

エラーについてのissue

github.com/AUTOMATIC1111/stable-diffusion-webui/issues/7714

issue先にも書いてあるけど、
webui起動前のセルに以下を挿入して実行すればいける

!cd /content/stable-diffusion-webui
!source ./venv/bin/activate
!pip install fastapi==0.90.1
!deactivate

2
Posted by 名無し(ID:RzLjzeiwaA) 2023年02月12日(日) 22:15:09 返信数(1) 返信

あざっす!解決しました

0
Posted by 名無し(ID:QsNwY2TsiQ) 2023年02月13日(月) 02:49:06

コメントをかく


「http://」を含む投稿は禁止されています。

利用規約をご確認のうえご記入下さい

Menu

Prompts

  1. 非R18詠唱全文
  1. 顔(目・口・表情)
  2. 構図
  3. 場所・背景
  4. 環境表現
  5. 特徴・年齢・体型・髪型
  6. ポーズ集
  7. 服飾
  8. 亜人・モンスター娘・人外
  9. 食品
  10. その他
  11. 画風
  12. 絵文字
  13. 色一覧
  14. 頻用ネガティブプロンプト
  15. 大量検証結果
  16. 整理用倉庫

編集中メニュー

  1. 未発見のプロンプト
  2. 旧ページ

table拡張js

どなたでも編集できます

メンバー募集!