概要
- 拡散モデルで画像+Promptから画像を生成したり、Propmtから画像を生成したりするソフト
Ubuntu 22.04 Installation
-
ハードウェア制約
- 6 GB くらいある GPU がないと厳しい
-
sudo apt install make build-essential libssl-dev zlib1g-dev libreadline-dev libbz2-dev libsqlite3-dev wget curl llvm libncurses5-dev
-
sudo apt install tk-dev
-
sudo apt install liblzma-dev
-
git clone https://github.com/basujindal/stable-diffusion-cd stable-diffusion
-
cd stable-diffusion
-
vi requirements.txt
albumentations==0.4.3
diffusers
opencv-python==4.1.2.30
pudb==2019.2
invisible-watermark
imageio==2.9.0
imageio-ffmpeg==0.4.2
pytorch-lightning==1.4.2
omegaconf==2.1.1
test-tube>=0.7.5
streamlit>=0.73.1
einops==0.3.0
torch-fidelity==0.3.0
transformers==4.19.2
torchmetrics==0.6.0
kornia==0.6
-e git+https://github.com/CompVis/taming-transformers.git@master#egg=taming-transformers -e git+https://github.com/openai/CLIP.git@main#egg=clip -e .
- vi ~/.bashrc # 以下を追記
export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
-
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
-
pyenv install 3.8.5
-
pyenv virtualenv 3.8.5 ldm
-
pyenv local ldm
-
mkdir -p models/ldm/stable-diffusion-v1
-
重みファイル sd-v1-4.ckpt を https://huggingface.co/CompVis/stable-diffusion-v-1-4-original からダウンロード
-
cp ~/Download/sd-v1-4.ckpt models/ldm/stable-diffusion-v1
サンプル
- cd ~/tmp/bas/stable-diffusion
- 文字から画像生成
- python3 optimizedSD/optimized_txt2img.py --prompt "Cyberpunk style image of a Telsa car reflection in rain" --H 512 --W 512 --seed 27 --n_iter 2 --n_samples 10 --ddim_steps 50
- 文字と画像から画像生成
- 画像元: https://gentosha-go.com/articles/-/43464
- python3 optimizedSD/optimized_img2img.py --prompt "with tall plants, a bed, a table and chairs" --init-img ~/Downloads/img_4b0c5ce1c17ec7e98b20922dc99aeb66103407.jpg --strength 0.6 --n_iter 2 --n_samples 1 --H 360 --W 640