Stable Diffusion
Categories:
Quick Start 1
よくわからない中でまずは動かしてみる目的。 pyenv
等の基礎知識があればインストールはスムーズに進む。動かしてみてわかったがバージョンが古い様子。
References
- Run Stable Diffusion on your M1 Mac’s GPU - Replicate – Replicate
- CompVis/stable-diffusion-v-1-4-original · Hugging Face
Python
$ python3 -V
Python 3.10.6
Stable Diffusion for Apple Silicon (version 1.4?)
bfirsh/stable-diffusion at apple-silicon-mps-support
git clone -b apple-silicon-mps-support https://github.com/bfirsh/stable-diffusion.git
cd stable-diffusion
mkdir -p models/ldm/stable-diffusion-v1/
python3 -m pip install virtualenv
python3 -m virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
brew install Cmake protobuf rust
Weights
Go to the Hugging Face repository, have a read and understand the license, then click “Access repository”.
Download sd-v1-4.ckpt
(~4 GB) on that page and save it as models/ldm/stable-diffusion-v1/model.ckpt
in the directory you created above.
Run it
python scripts/txt2img.py \
--prompt "a red juicy apple floating in outer space, like a planet" \
--n_samples 1 --n_iter 1 --plms
python scripts/txt2img.py \
--prompt "illuminated tokyo tower highly detailed shot from above SIGMA 85 mm F1.4 award winning cinematic scene cinematic composition cinematic lighting" \
--n_samples 1 --n_iter 1 --plms
python scripts/txt2img.py \
--prompt "beautiful princess beautiful face beautiful hair beautiful clothes artstation fantasy scene fantasy composition fantasy lighting octane render" \
--n_samples 1 --n_iter 1 --plms
Quote prompt:
python scripts/txt2img.py \
--prompt "profile icon of a portrait of a nice boy with a perfect face and middle hair and tattoo on her cheek, back view, anime, artistic, captivating, aesthetic, hyper-detailed and intricate, realistic shaded, realistic proportion, symmetrical, concept art, full resolution, golden ratio, global resolution, sharp focus" \
--n_samples 1 --n_iter 1 --plms
python scripts/txt2img.py \
--prompt "profile icon of a portrait of a nice boy with a perfect face and middle hair and, anime, artistic, captivating, aesthetic, hyper-detailed and intricate, realistic shaded, realistic proportion, symmetrical, concept art, full resolution, golden ratio, global resolution, sharp focus" \
--n_samples 1 --n_iter 1 --plms
Quick Start 2
ここまでで掲載した画像は Stable Diffusion 1.4 による生成。
2022/12/09現在、 Stable Diffusion 2.1 が出ている。Apple からの News も出ているので、別のレポジトリで試す。
TODO (要確認)
- stabilityai/stable-diffusion-2-1 · Hugging Face
- Stable Diffusion with Core ML on Apple Silicon - Apple Machine Learning Research
- apple/ml-stable-diffusion: Stable Diffusion with Core ML on Apple Silicon
Quick Start 2 (AUTOMATIC1111: Web UI version)
お手軽に Web UI を用意できる。
AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI
Apple Silicon 利用手順: Installation on Apple Silicon · AUTOMATIC1111/stable-diffusion-webui Wiki
- しかし Stable Diffusion 2.0 以降は、縦横 768px 以上にすることが求められるようで、その結果生成が非情に遅くなる(CPUでは画像ガチャが厳しい)
- Quick Start 1 にて試した Prompt を入れてもかなり期待はずれの画像が生成されてしまう。要検討
関連情報
- propose an Contrastive Prompt Tuning method (DreamArtist), can super dramatically improve the image quality and diversity by 7eu7d7 · Pull Request #2945 · AUTOMATIC1111/stable-diffusion-webui
- 7eu7d7/DreamArtist-stable-diffusion: stable diffusion webui with contrastive prompt tuning
- Stable Diffusion 2.1-美少女アニメ画 - ISID テックブログ