Skip to content

Instantly share code, notes, and snippets.

@james-see
Created September 6, 2022 14:42
Show Gist options
  • Save james-see/0bdf11faadfa50d18f91119a4d9d368b to your computer and use it in GitHub Desktop.
Save james-see/0bdf11faadfa50d18f91119a4d9d368b to your computer and use it in GitHub Desktop.
img2img Mac M1

This guide assumes you already have checked out the apple-silicon-mps-support branch from https://github.com/bfirsh/stable-diffusion

Steps

  • Add the sys path line to img2img.py above the ldm imports like so
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
from ldm.util import instantiate_from_config
from ldm.models.diffusion.ddim import DDIMSampler
from ldm.models.diffusion.plms import PLMSSampler
  • Ensure your base image is 512x512. I have heard that any multiple of 16 works, but I have not tested.

  • Ensure you pass in the runtime variable --precision full like so

python scripts/img2img.py --prompt "portrait of a lady leaning out a window looking out at the water \
from inside, painting by Edward Hopper" --init-img ~/Downloads/hopper.jpeg --n_samples 1 --n_iter 1 \
--precision full --strength 0.8

Troubleshooting

If things are not working:

  • Ensure you have activated the virtual environment and saved the model in the correct location for the script to pick it up with the right model name
  • Ensure you added the sys line above the ldm imports
  • Ensure your base image is 512x512
  • Ensure you have checked out the right branch (I haven't tried the anaconda version

Extra Help

twitter: jc50000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment