From 0 to 1, from entry to advanced to play AI - Stable Diffusion ultra-detailed tutorial (1)

cutting edge

        At present, AI on the market is mainly concentrated in two aspects. One is AI mapping (representative products: Midjourney and Stable-Diffusion), and the other is AI response (representative product: ChatGPT). This paper mainly explores AI mapping.

        Since Midjourney is a paid product, the biggest advantage of Stable-Diffusion is that it is open source and free. Because of open source and free, Stable-Diffusion has a large number of active community users, and the developer community also provides a large number of free, high-quality external pre-training models (fine-tune) and plug-ins. With the support of the community, Stable-Diffusion Compared with Midourney, it has richer personalized functions. After fine-tuning, it can generate pictures that are closer to the needs, AI video special effects, etc.

        Stable-Diffusion is actually a latent diffusion model (Latent Diffusion Model), which can generate graphics through text descriptions, so it can be used in scenarios such as image restoration, image rendering, and text-to-image conversion.

hardware requirements

Because a large number of calculations are required to achieve image rendering, there are certain requirements for computer hardware:

1. It is recommended to use N card (Nvida independent graphics card), minimum 4G video memory, RTX3050 graphics card or above;

You can check "Dedicated GPU memory" through [Task Manager] - [Performance] - [GPU1] (NVIDIA GeForce...)

2. The minimum memory is 8G;

3. Hard disk 50G or more solid state hard disk.

prepare software

1.git : A tool for downloading open source software on github

2.python-3.10.6: Python operating environment, here due to the stable-diffusion-webui project dependency requirements, it must be version 3.10.6

3.AUTOMATIC1111/stable-diffusion-webui: It provides a Gradio library-based web interface for Stable-Diffusion. The software provides a one-click installation program to download Stable-Diffusion and related dependencies by itself.

Software Installation

Python environment installation

Download the Python 3.10.6 version from the official website, download link: Python Release Python 3.10.6 | Python.org

After the download is complete, you can install it. Note: Remember to check "Add Python 3.10 to PATH" when installing. In addition, I chose the custom location (Customize installation) when installing here (personal obsessive-compulsive disorder). If you want to save trouble, you can also Just click "Install Now" to install.

I won’t say much about the installation process. After the installation is over, it is recommended to disable the path length limit. Click on the picture below: “Disable path length limit”.

After the installation is complete, open a cmd window to verify that python is installed successfully, using the command: python -V

Git tool installation

Download the latest version of Git from the official website at: Git - Downloading Package (git-scm.com)

Personal obsessive-compulsive disorder, I downloaded the 64-bit portable version (no need to install, but you need to manually set the environment variables), after the download is complete, unzip it to the corresponding location (my location: D:\Environments\git).

Modify the Path environment variable: [This computer] right click - [Properties] - [System] - [Advanced System Settings] - [Advanced] - [Environment Variables] - find "Path" in "System Variables" , double-click to edit - add "D:\Environments\git\bin", confirm to complete the environment variable configuration.

Note: The ./git/bin path should be located in the environment variable, because the portable version of the command tool is in this directory

 Open a new cmd window, verify git and configure git

Check the git version: git -v

Configure git name and email:

git config --global user.name "xxxxx"
git config --global user.email "[email protected]"

 Since then git installation is complete

Download and install the Stable-Diffusion-WebUI tool

Download the source code on github through the git tool, download address: GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI

 1. Create a location on the local hard disk to store and install Stable-Diffusion-WebUI (my path is D:/Workspace), then right-click on the folder, select [Git Bash Here], and a git will be opened automatically terminal.

 Enter the command in the "small black window":

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

Press enter to start downloading Stable-Diffusion-WebUI

After the download is complete, you can see the downloaded program stable-diffusion-webui

 Enter the folder, find "webui-user.bat" at the bottom and execute it. During the process, please ensure that the network is normal, because it will start the automatic download program to download related dependent plug-ins (about 6G local space), download and install It will take a long time, please be patient...

 Note: If the installation process fails, you can execute it according to the failure feedback information (or refer to the "FAQ" below to find the solution), and execute "webui-user.bat" again after the execution is completed until the installation is successful.

Access address: http://127.0.0.1:7860

The prompt words can refer to the following two sites:

Arthub.ai: Discover, Upload and Share AI Generated Art

Vocabulary

For other personalized operations, please see the content of the next article, I hope it will be helpful to you!

common problem

fatal: unable to access 'xxxx' OpenSSL SSL_read:Connection was reset,erro 10054

Note: If you follow the above steps, the prompt "fatal: unable to access 'xxxx' OpenSSL SSL_read: Connection was reset, erro 10054" appears. The problem at this time is that git verifies the https certificate. We can use the command:

git config --global http.sslVerify false

 Turn off certificate verification, and then execute the above download command to download normally.

Stuck for a long time while "Installing gfpgan"

When you get stuck for a long time during the execution of "Installing gfpgan", the installation will basically fail. This is due to network reasons, and the program cannot be downloaded from github. Even if it is scientifically online, it is difficult, so it is recommended to use manual installation method, the operation steps are as follows:

1) Manually download GFPGAN from GitHub - TencentARC/GFPGAN: GFPGAN aims at developing Practical Algorithms for Real-world Face Restoration.

 2) Unzip the downloaded compressed package GFPGAN-master to the venv/Scripts/ directory under your stable-diffusion-webui storage path (for example: my path is: D:\Workspace\stable-diffusion-webui\venv\ Scripts\GFPGAN-master)

3) Open cmd and switch the path to the workspace

cd /D D:\Workspace\stable-diffusion-webui\venv\Scripts

Then execute the command to install the dependent program of gfpgan

python.exe -m pip install --upgrade pip
python.exe -m pip install basicsr facexlib
cd GFPGAN-master
python.exe -m pip install -r requirements.txt

4) After the installation is complete, execute "webui-user.bat" again, and generally gfpgan can be installed successfully.

But then the clip may encounter the same problem and the installation fails, continue to install manually

1) Manually download open_clip, download address: GitHub - mlfoundations/open_clip: An open source implementation of CLIP.

2) Unzip the compressed package open_clip-main to the venv/Scripts/ directory under your stable-diffusion-webui storage path (for example: my path is: D:\Workspace\stable-diffusion-webui\venv\Scripts\open_clip -main)

3) Open cmd and switch the path to the open_clip-main directory (be sure to switch to open_clip-main, because we will compile and install clip next)

cd /D D:\Workspace\stable-diffusion-webui\venv\Scripts\open_clip-main

4) Execute the command to install clip (because the directory levels of python.exe and clip are different, so python.exe needs to use an absolute path, windows is troublesome and cannot be used../)

D:\Workspace\stable-diffusion-webui\venv\Scripts\python.exe setup.py build install

5) After the open-clip is installed, you need to manually install the clip

cd ..
pip install clip

5) After the installation is complete, execute "webui-user.bat" again. Generally, gfpgan can be installed successfully.

Note: If the installation process fails, you can execute it according to the failure feedback information. After the execution is completed, execute "webui-user.bat" again until the installation is successful.

When "Installing requirements" prompts connection timeout exception

When executing "Installing requirements", the error shown in the figure below may occur multiple times, indicating that the connection timeout is abnormal, which means that the network is unstable, and you can try again. If the same error still occurs after multiple retries, you can manually increase the delay and install This problem can be solved by related plug-ins.

As can be seen from the figure above, there is a timeout exception in the installation of the accelerate and numpy plug-ins, so use the command to install them manually, and set the timeout to 1000 milliseconds to find that the installation is successful (other similar problems can be handled in the same way as below):

pip --default-timeout=1000 install accelerate

After the installation is complete, execute "webui-user.bat" again to complete the installation normally.

Guess you like

Origin blog.csdn.net/Asgard_Hu/article/details/131003648