pythonmacosartificial-intelligencestable-diffusion

How to install Stable Diffusion web UI from AUTOMATIC1111 on a Mac Intel?


I've recently tried to use the Stable Diffusion web UI from AUTOMATIC1111 on my Mac Intel. There is no documentation for Mac Intel, and when I tried to use the methods presented for other platforms, I ended-up with a Python exception related to LZMA:

ModuleNotFoundError: No module named '_lzma'

I was able to fix the problem thanks to this stack overflow post. This allowed me to write an installation guide / documentation for Mac Intel that I share in my answer.

My configuration:


Solution

  • Prerequisites:

    Installation guide:

    1. Open a Terminal and move to the directory where you want to install Stable Diffusion web UI.

    2. Using the Terminal, clone the stable-diffusion-webui repo. This will create a stable-diffusion-webui directory. Once the cloning is done, move into this directory:

    $ git clone git@github.com:AUTOMATIC1111/stable-diffusion-webui.git
    $ cd stable-diffusion-webui
    
    1. Using the Terminal, install xz with brew. Note that this needs to be done before installing Python 3.10:
    $ brew install xz
    
    1. Using the Terminal, install Python 3.10 using pyenv. Then set the local Python version to 3.10 in the stable-diffusion-webui directory. This will only affect the Python version used within this directory, the default Python version will be unchanged:
    $ pyenv install 3.10
    $ pyenv local 3.10
    
    1. Download a Stable Diffusion model checkpoint. I downloaded the 1.5 version (v1-5-pruned.ckpt file) from the Hugging Face website. Then move the checkpoint into the models/Stable-diffusion directory.

    2. Using the Terminal, run the webui.sh script:

    $ ./webui.sh
    

    If everything went fine, you should have in the Terminal a message that looks like this:

    Running on local URL: http://127.0.0.1:7860
    
    1. Open the URL in an Internet browser. In the txt2img tab, enter a prompt and click the generate button. This will start the image generation process.

    The image I attached to this post was generated on my MacBook Pro Intel.

    Image computed using Stable Diffusion web UI