1. はじめに
画像生成が可能なAIであるStable Diffusionをブラウザから利用する際には、Automatic1111、WebUI Forge、ComfyUIなどの選択肢が存在する。今回はStable Diffusion Web UI(AUTOMATIC1111)をIBM Cloud上のVSI for VPC環境で試してみた。
なお、GPUはIBM Cloud: RHEL9 + NVIDIA A100環境にNVIDIA Driverをインストールするを使って構成済みである。
※今回は色々な検証のついでに触ったのでA100を流用しているが、Stable Diffusion web UIを動かすだけならもっとVRAMサイズが小さいGPUで良い。
2. インストール
[vpcuser@syasuda-ollama ~]$ cat /etc/redhat-release
Red Hat Enterprise Linux release 9.6 (Plow)
[root@syasuda-ollama ~]# dnf install -y wget git python3 gperftools-libs libglvnd-glx
[root@syasuda-ollama ~]# dnf install -y bc
[root@syasuda-ollama ~]# wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh
3. webui.shの実行(デフォルト)
[root@syasuda-ollama ~]# bash webui.sh
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye), Fedora 34+ and openSUSE Leap 15.4 or newer.
################################################################
################################################################
ERROR: This script must not be launched as root, aborting...
################################################################
[root@syasuda-ollama ~]# su - vpcuser
[vpcuser@syasuda-ollama ~]$ bash webui.sh --listen
[vpcuser@syasuda-ollama ~]$ ss -anpt |grep -e State -e 7860
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 2048 0.0.0.0:7860 0.0.0.0:* users:(("python",pid=12376,fd=56))
[vpcuser@syasuda-ollama ~]$ ls -l
total 16
drwx------. 22 vpcuser vpcuser 4096 Aug 28 04:41 stable-diffusion-webui
-rw-------. 1 vpcuser vpcuser 11221 Aug 28 04:20 webui.sh
[vpcuser@syasuda-ollama ~]$ du -sh stable-diffusion-webui
9.3G stable-diffusion-webui
4. Stable Diffusion web UIで画像生成した結果
プロンプトにメッセージを入れてGenerate
を押せば画面が生成される。色々なパラメーターを変更したり、バッチサイズ(同時に生成する画像の数)を大きくするなどのカスタマイズが可能。
とはいえ、モデルによって得意・苦手はあるので、プロンプトチューニングだけでは限界があり、実際はアニメ系や実写系など得意なジャンルに応じたモデルをダウンロードして利用すると、より品質の高い画像が生成される。全く同じ指示(Beautiful green-haired girl elf living in the forest, anime style.
)で異なるモデルを利用した際の例は以下の通り。
- デフォルトでインストールされているv1-5-pruned-emaonly
-
WAI-NSFW-illustrious-SDXL
-
yayoi_mix
-
Anime Pastel Dream