Python AI painting

Python AI painting

In this article, we will introduce how to build your own AI drawing tool based on some open source libraries.

The open source library to be used is Stable Diffusion web UI, which is a Stable Diffusion browser interface based on the Gradio library

Stable Diffusion web UI GitHub 地址:GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI

Running Stable Diffusion requires relatively high hardware requirements, and it will consume a lot of resources when running, especially the graphics card.

Windows environment installation

The local environment requires Python 3.10.6 or above to be installed and added to the local environment variables.

Download Stable Diffusion web UI GitHub source code GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI .

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

If Git is not installed, you can download the zip archive in the upper right corner.

51349944d7619431767414a9eaf01a7b.png

Unzip stable-diffusion-webui and enter the stable-diffusion-webui directory.

Next we need to download the model, download address: https://huggingface.co/CompVis/stable-diffusion-v-1-4-original

44be9912c57ee5d4d1543d1e54392da1.png

Move the downloaded model to the stable-diffusion-webui/models/Stable-diffusion directory.

Enter the stable-diffusion-webui directory:

Windows run as non-administrator:

webui-user.bat

Linux and Mac OS environments execute the following commands:

./webui.sh

Next, the program will be automatically installed and started. If the startup is successful, you will see an accessible URL address http://127.0.0.1:7860:

7d6137a76b3d28b7dfbbe01d63ff66af.png

Visit http://127.0.0.1:7860, the interface is as follows:

87080639f2e4fbf8de6fb352bbcb4abd.png

Note: If the installation is stuck, it is likely that there is a problem with downloading the Github source code. You can use some Github mirrors to solve it. There is no very stable mirror at present. It is recommended to search on Google. I use the following mirror address https://hub.fgit.ml on April 6, 2023, open the launch.py ​​file in the stable-diffusion-webui directory, and replace the Github address of the following part of the code (the code is about 230~ 240 lines):

c493adb3854a513a822e19e0f74669e0.png

Introduction to Civitai

Civitai has many customized models, and they can be downloaded for free. We use the Guofeng 3 model for testing. Download address: https://civitai.com/models/10415/3-guofeng3?modelVersionId=36644

a6486dc6da2f282ddfd63553191fa21a.png

After downloading, we move the model to the stable-diffusion-webui/models/Stable-diffusion directory and restart stable-diffusion-webui:

./webui.sh

In this way, we can select the Guofeng 3 model in the model list :

d36d0807d4805fbcc02620d7f6199a95.png

After selection, we can go to the model introduction page to copy some prompt words and test parameters:

8939a49ade6a6820dd5c8fb03f168dd3.png

276be603056fd1023a69a64f0796ae46.png

27ad721f84bb7acea9d0cf4cf1e23810.png

​In order to generate quickly, I halved the height and width, and then click the generate button:

0d0976acb6702cc2b81bc3671748bddb.png

 

 

Guess you like

Origin blog.csdn.net/2301_78835635/article/details/131502550