This assumes you have homebrew installed from https://brew.sh/ but if you have a Rust compiler and a Python 3 installation, you don't need it.
- Create an account at https://huggingface.co/join
- Go to https://huggingface.co/CompVis/stable-diffusion-v1-4 and accept the ToS
- Create a new token at https://huggingface.co/settings/tokens
brew install rust [email protected] # if you don't already have these
python3 -m venv stablediff
source stablediff/bin/activate
pip install --upgrade pip setuptools wheel
pip install ipython
pip install diffusers==0.2.4
pip install "ipywidgets>=7,<8"
pip install transformers scipy ftfy
Run huggingface-cli login
Run ipython
and then:
import time
import torch
from IPython.display import Image
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", use_auth_token=True)
def generate_image(prompt, num_steps=50):
seed = torch.manual_seed(time.time())
images = pipe([prompt], num_inference_steps=num_steps, guidance_scale=7.5, generator=seed)["sample"]
return images[0]
image = generate_image("Dogs playing poker")
image.show()