Installing Stable Diffusion (Linux)

https://github.com/invoke-ai/InvokeAI (this is what this tutorial uses) https://github.com/magnusviri/stable-diffusion#installation https://github.com/CompVis/stable-diffusion

cd stable-diffusion/

conda env create -f environment.yaml
conda activate ldm
pip list
pip install pytorch-lightning
pip install omegaconf
pip install einops
pip install transformers
pip install k_diffusion
pip install git+https://github.com/crowsonkb/k-diffusion/
pip install taming-transformers
pip install taming-transformers-rom1504
  • pytorch is a deep learning framework.
  • omegaconf is a config
  • einops is a deep learning Einstein-Inspired Notation for operations
  • transformers are for deep learning
  • k_diffusion is a sampler
    curl https://www.googleapis.com/storage/v1/b/aai-blog-files/o/sd-v1-4.ckpt?alt=media > sd-v1-4.ckpt

    mkdir -p models/ldm/stable-diffusion-v1

    mv sd-v1-4.ckpt models/ldm/stable-diffusion-v1/model.ckpt

    python scripts/preload_models.py
python scripts/dream.py
  • if you haven't got an nvidia card

python scripts/dream.py --full_precision

python scripts/txt2img.py --prompt "YOUR-PROMPT-HERE" --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1

python scripts/txt2img.py --prompt "YOUR-PROMPT-HERE" --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1

Dream examples

dream> "waterfall and rainbow" --init_img=./init-images/crude_drawing.png --strength=0.5 -s100 -n4

dream> "there's a fly in my soup" -n6 -g

dream> "an iron cage by a lake" -n1 -g

dream> ashley judd riding a camel -n2 -s150

examples from a file

python3 scripts/dream.py --from_file "path/to/prompts.txt"

prompts.txt

a beautiful sunny day in the park, children playing -n4 -C10
stormy weather on a mountain top, goats grazing     -s100
innovative packaging for a squid's dinner           -S137038382

web browser

python3 scripts/dream.py --web

connect via http://localhost:9090

Installing on mac

(https://twitter.com/levelsio/status/1565731907664478209)

 pre-requisites

brew update
brew install python
cd stable-diffusion-main
mkdir -p models/ldm/stable-diffusion-v1
python3 -m pip install virtualenv
python3 -m virtualenv venv
source venv/bin/activate
brew install Cmake protobuf rust
pip install -r requirements.txt

Download sd-v1-4.ckpt (~4 GB) and save it under stable-diffusion/models/ldm/stable-diffusion-v1/model.ckpt

test:

python scripts/txt2img.py --n_samples 1 --n_iter 1 --plms --prompt "new born baby kitten. Hyper Detail, 8K, HD, Octane Rendering, Unreal Engine, V-Ray, full hd"

adjust detail:

Ah ok so you can type as CLI param:

--ddim_steps 1

It defaults to 50 which takes 30 seconds on M1 16" for me

These pics are:

--ddim_steps 1 (0.6 secs) --ddim_steps 10 (6 secs) --ddim_steps 50 (30secs) --ddim_steps 100 (1min)

And here's some random text prompts I collected that I add at the end of every prompt I type that make it very pretty:

cinematic photo, highly detailed, cinematic lighting, ultra-detailed, ultrarealistic, photorealism, 8k, octane render

cyberpunk lights, Hyper Detail, 8K, HD, Octane Rendering, Unreal Engine, V-Ray, full hd

cyberpunk, abstract, full hd render + 3d octane render +4k UHD + immense detail + dramatic lighting + well lit + black, purple, blue, pink, cerulean, teal, metallic colours, + fine details + octane render + 8k

breathtaking detailed concept art painting art deco pattern - blue flowers with anxious piercing eyes and blend of flowers and birds, by hsiao - ron cheng and john james audubon, bizarre compositions, exquisite detail, extremely moody lighting, 8 k

ultra photoreal , photographic, concept art, cinematic lighting, cinematic composition, rule of thirds , mysterious, eerie, cinematic lighting, ultra-detailed, ultrarealistic, photorealism, 8k, octane render,

painted by greg rutkowski makoto shinkai takashi takeuchi studio ghibli, akihiko yoshida

If you quit the Terminal or reboot, you get kicked out of the virtualenv, to get back in type:

source venv/bin/activate

And run you rprompt

python scripts/txt2img.py --n_samples 1 --n_iter 1 --plms --prompt "your text here"

NSFW filter:

https://www.reddit.com/r/StableDiffusion/comments/wv2nw0/tutorial_how_to_remove_the_safety_filter_in_5/