29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 925bd947d7, Model: CyberRealistic_V4.1_FP32, Version: v1.7.0
とりあえず子どものGaming PCでやっていたStable Diffusionの画像生成はできるようになりました。上の画像は前回 の”29 years old beautiful female Japanese IT Professional”のプロンプトをCyberRealistic というモデルで処理してみたものです。悪くないけどやや目を強調しすぎ(プリクラの影響?)かな?512×512のイメージだと1枚1秒くらいで生成するので楽勝です。
すぐにバージョンが変わって情報が古くなるので、ちゃんとしたセットアップ・ガイドを提供するつもりはないんですが、いちおうやったことの概略をここにメモしておきます。
Ubuntu 24.04.3 LTS をインストールする。英語でインストールしました。設定のほとんどはデフォルトのままですが、”Install third-party software for graphics and WiFi hardware and additional media formats”というのにはチェックを入れました。
リブートして、ターミナルで nvidia-smi コマンドというのをたたいてやると、ドライバーのバージョンが出る。ここで、ぼくの場合、ディスプレイドライバーのバージョンが”535″、CUDAのバージョンが”12.2″と表示されました。きょう現在(2024-02-17) CUDAのバージョンが12.1以下じゃないと、パッケージ済みのPyTorch(これがStable DiffusionのUIとなるwebuiというやつを動かすのに必要)をインストールできないので、これをダウングレードしなければいけない。
そんなわけで、ここのページに紹介されている手順 でいったんインストールしたドライバーをアンインストールする。
先のステップの最後で ubuntu-drivers devices というコマンドでおすすめのドライバーのバージョンを表示させて、そのおすすめバージョンをインストールしろということになっているけど、それは無視して、”525″というバージョンをインストールする。つまり、 sudo apt install libnvidia-common-525 libnvidia-gl-525 nvidia-driver-525 -y
インストールが終了したら、リブートして、また nvidia-smi コマンドを打つ。ここで、ディスプレイドライバーのバージョンが”525″、CUDAのバージョンが”12.0″と表示されていればOK。
つぎのステップの準備として西川和久さんが紹介されている方法 でMinicondaをインストールしてPython 3.10.6のconda環境をつくってactivateしておく。
Ubuntuにはデフォルトで git がインストールされないようなので、sudo apt install git でインストールする。
ワークディレクトリをつくって、git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git でwebui のリポジトリをcloneする。
なにかモデルがないといかんので、とりあえずStable Diffusion 2.1のベースモデル v2-1_512-nonema-pruned.safetensors というのをHugging Face からダウンロードして、webuiをcloneしたディレクトリの下のmodels/Stable-diffusionにmoveする。
ここでwebuiをcloneしたディレクトリにあるwebui.shを動かしてやる ( ./webui.sh )と必要なライブラリ(PyTorchとか)をダウンロードして、webuiが立ち上がる(はず)。うまく行ったら、 Calculating sha256 for /home/tami/git/AUTOMATIC1111/stable-diffusion-webui/models/Stable-diffusion/v2-1_512-nonema-pruned.safetensors: Running on local URL: http://127.0.0.1:7860 というようなメッセージが出る。
で、ブラウザで http://127.0.0.1:7860 を開けたら Stable Diffusionがつかえるようになっているはず。
このままでも動くんですが、Cannot find TCMalloc (improves CPU memory usage) というメッセージが赤色で表示されてちょっと気になるので、しらべてみたら 、 sudo apt-get install google-perftools でメッセージが消えるみたいです。
あと前にWSLで動かしたときに見たページ にあったシェルスクリプトをStable Diffusion立ち上げ用に作っておくと便利です。こんな感じ:
#!/bin/bash
# Function to handle cleanup actions
cleanup() {
# Perform cleanup actions here
echo "Performing cleanup..."
# Remove files named tmp*.png in /tmp folder
rm -f /tmp/tmp*.png
# Remove files named tmp*.jpg in /tmp folder
rm -f /tmp/tmp*.jpg
# Remove gradio folder if it exists
rm -rf /tmp/gradio
# Remove tmp* folders within /tmp directory
rm -rf /tmp/tmp*
}
# Trap SIGINT signal (Ctrl+C) and call cleanup function
trap cleanup SIGINT
# Change directory
cd /home/tami/git/AUTOMATIC1111/stable-diffusion-webui
# Run webui.sh script
./webui.sh
# Cleanup actions after Python script termination
cleanup
以上です。インストールをやり直したりしてちゃんとこの手順だけでインストールできるかどうか確認してないので、必要なステップが抜けてたらすみません。
Seedを固定していくつか他のモデルも試してみたので載せておきます。個人的にはRealisticVisionが好きですが、けっこうベースモデルもいいのではないかとおもいます。あんまり美人・美少女に特化しちゃうとリアリティが失われてしまう、ということかな。
Stable Diffusion 2.1ベースモデル
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: fc4f9fe752, Model: v2-1_512-nonema-pruned, Version: v1.7.0
BeautifulRealistic
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 1a17bcd93d, Model: beautifulRealistic_v7, Version: v1.7.0
majicmixRealistic
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 33c9f6dfcb, Model: majicmixRealistic_v5, Version: v1.7.0
RealisticVision (前回のやつ)
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 00445494c8, Model: Realistic_Vision_V5.1, Version: v1.7.0
Agelesnate (これも前回のやつ)
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 870d7132aa, Model: agelesnate_v3, Version: v1.7.0
MeinaMix
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: eac6c08a19, Model: Meina V9 – baked VAE, Version: v1.7.0
Stable Diffusion 2.0ベースモデル
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: ab800444cd, Model: 512-base-ema, Version: v1.7.0
AbsoluteReality
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 463d6a9fe8, Model: absolutereality_v181, Version: v1.7.0
epiCRealism
29 years old beautiful female Japanese IT Professional in a plain beige oversized T shirt with light brown short choppy hair at a coffee shop, high quality, pink tiny lips, small nose, full body, holding a cup, along counter, dim light, thin arms, looking straight, sister Negative prompt: low quality, big breast Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 1757170746, Size: 512×512, Model hash: 84d76a0328, Model: epicrealism_naturalSinRC1VAE, Version: v1.7.0