HomeTutorials
[StableDiffusion Novice Tutorial] How to perform local deployment on Mac (M chip)
46

[StableDiffusion Novice Tutorial] How to perform local deployment on Mac (M chip)

Noodleplan-icon
Noodle
March 13th, 2023
View OriginalTranslated by Google

Software and hardware requirements

  • A Mac computer, the system is M1 or M2, and the memory is more than 8G (the bigger the better, the bigger the faster).
  • The free space of the hard disk should be at least 10G or more, preferably more than 30G.
  • You need to be able to access the internal and external networks smoothly.

Installation process

1. Install homebrew and open the terminal terminal (command + space bar, enter terminal, press Enter to open), install homebrew. (If already installed, skip to the next step)

2. Copy and execute the following code (official version) in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

If the network problem has not responded or reported an error, you can use the domestic mirror version:

/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"

Check if homebrew is installed successfully

brew -v

If the version information of homebrew is displayed, the installation is successful.

if it shows

zsh: command not found: brew

You need to add Homebrew to the environment variable PATH, and give the corresponding operation steps. Users need to configure environment variables according to the suggestions given in order to use Homebrew normally in the terminal. Execute immediately in the current terminal/shell

eval "$(/opt/homebrew/bin/brew shellenv)"

3. Install python Open a new terminal window and run:

brew install cmake protobuf rust python@3.10 git wget

4. Install stable-diffusion-webui If git is not installed, install git first. Run in Terminal:

brew install git

Then use git to clone all the github open source programs of stable diffusion webui to your Mac computer locally, and execute in the terminal:

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui

5. Download the basic model of ai drawing Here, take the Stable Diffusion 2.0 training model as an example, find and download 768-v-ema.ckpt in the "file" tag of the https://huggingface.co/stabilityai/stable-diffusion-2 page. After downloading, put the downloaded ckpt file in the "Your Username" > Stable-diffusion-webui > Models > Stable-diffusion folder. 6. Run stable-diffusion-webui Use the terminal to enter the stable-diffusion-webui folder. run

cd stable-diffusion-webui

Open stable-diffusion-webui, run

./webui.sh

This step may take a long time as several SD-required apps are downloaded. If there is no progress for a long time and various errors are reported, use the finder to open the stable-diffusion-webui folder, find the launch.py ​​and other files, and open them with the text editing software that comes with the system, about 200-300 lines , find something like

"gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+ https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 ")"

paragraphs. And add: " https://ghproxy.com/ " at the front of " https://github.com/xxx ", so that the system downloads related applications will be modified to download from domestic mirror stations, which will be more stable and faster . After adding it, it will become something like:

"gfpgan_package = os.environ.get('GFPGAN_PACKAGE', "git+ https://ghproxy.com/https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 ")"

of text. Add a few lines before and after gfpgan, and the paragraph with the github URL. Similar to the picture below:

Save and close the launch.py ​​file. Re-run ./webui.sh, then wait a few minutes and it will be ready. until the terminal displays

“Running on local URL: http://127.0.0.1:7860 To create a public link, set share=True in launch() .”

7. Open the stable-diffusion-webui web version Be careful not to close the small terminal window, open a browser (Safari or Chrome) and enter http://127.0.0.1:7860 to access the local web version of the stable diffusion webui

Next, you can enter the prompt words in the prompt box, and then click Generate to generate the AI ​​drawing.

How to do local deployment on Windows, please click here .

Comments