赞
踩
最近两年AI技术非常火爆,特别是今年随着ChatGPT被吹爆,更多的AI技术映入大家眼帘。相较于其他AI,感觉AI绘画更接地气,sd webui全名:Stable Diffusion web ui是AI绘画中的一种算法,是一个文本到图像的潜在扩散模型,只需要输入“咒语”,AI理论上就可以画出任何图像。它最火爆的原因还是开源,众所周知,民间出大神,给了我们拾人牙慧的机会。
服务器: DeLL R940xa
内存: 256G
处理器: Intel® Xeon® Gold 5218 CPU @ 2.30GHz
GPU: NVIDIA A2 *4
**必备条件:**加速器、git、二选一:python3.10.6或Anaconda(直接使用Anaconda创建Python3.10.6可以解决很多麻烦问题)、选择python3.10.6需要openssl 1.1.1以上版本
准备环境:安装Python3.10.6点击下载,先升级openssl,升级gcc
[root@DevonL ~]# yum install wget ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel zlib zlib-devel net-tools [root@DevonL ~]# cd /usr/local/src/ [root@DevonL src]# wget https://www.openssl.org/source/old/1.1.1/openssl-1.1.1t.tar.gz [root@DevonL src]# tar xf openssl-1.1.1t.tar.gz [root@DevonL src]# cd openssl-1.1.1t [root@DevonL src]# ./config --prefix=/usr/local/openssl [root@DevonL src]# make && make install [root@DevonL src]# mv /usr/bin/openssl /usr/bin/openssl.bak [root@DevonL src]# mv /usr/include/openssl /usr/include/openssl.bak [root@DevonL src]# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl [root@DevonL src]# ln -s /usr/local/openssl/include/openssl /usr/include/openssl [root@DevonL src]# ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/lib64/libssl.so.1.1.1 [root@DevonL src]# ln -s /usr/local/openssl/lib/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1 [root@DevonL src]# openssl version OpenSSL 1.1.1t 7 Feb 2023 [root@DevonL src]# cd /usr/local/src/ [root@DevonL src]# tar xf Python-3.10.6.tar.xz [root@DevonL src]# cd Python-3.10.6 [root@DevonL src]# ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl/ [root@DevonL src]# make [root@DevonL src]# make install [root@DevonL src]# ln -s /usr/local/python3/bin/python3.10 /usr/bin/python3 [root@DevonL src]# ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip3 [root@DevonL src]# yum install centos-release-scl [root@DevonL src]# yum install devtoolset-9-gcc* [root@DevonL src]# yum install libtcmallo-* [root@DevonL src]# mv /usr/bin/gcc /usr/bin/gcc-4.8.5 [root@DevonL src]# mv /usr/bin/g++ /usr/bin/g++-4.8.5 [root@DevonL src]# ln -s /opt/rh/devtoolset-9/root/bin/gcc /usr/bin/gcc [root@DevonL src]# ln -s /opt/rh/devtoolset-9/root/bin/gcc /usr/bin/gcc [root@DevonL src]# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) [root@DevonL src]# git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git [root@DevonL src]# pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 [root@DevonL src]# useradd test [root@DevonL src]# passwd test [root@DevonL src]# chown test.test stable-diffusion-webui -R [root@sdwebui stable-diffusion-webui]# su test [test@sdwebui stable-diffusion-webui]# [test@sdwebui stable-diffusion-webui]# ./webui.sh #有些依赖可能无法下载成功,需要手动进行下载。
[root@DevonL ~]$ cd /usr/local/src/stable-diffusion-webui/extensions/
[root@sdwebui extensions]# git clone https://github.com/ototadana/sd-face-editor.git
[root@sdwebui extensions]# git clone https://github.com/journey-ad/sd-webui-bilingual-localization
[root@sdwebui extensions]# git clone https://github.com/Mikubill/sd-webui-controlnet.git
[root@sdwebui extensions]# chmod test.test * -R
[root@sdwebui stable-diffusion-webui]# su test
[test@DevonL stable-diffusion-webui]$ ./webui.sh
启动,使用IP:7860进行访问
点击下载汉化文件
将该zh_CN.json文件,移动到sd webui localization目录下
[root@DevonL localizations]# pwd
/usr/local/src/git/stable-diffusion-webui/localizations
[root@DevonL localizations]# ls
Put localization files here.txt zh_CN.json
[root@DevonL localizations]# chown test.test zh_CN.json
启动之后,找到Extensions(扩展),Apply and restart UI(应用并重启UI界面)
Settings(设置)—User interface(用户界面)----Localization(None)
显示所有页面
设置为zh_CN
先Apply settings 后reload UI,之后就是汉化。
选择要使用的模型,然后在提示词中写入你想生成的人物、景色,尽量细节,人物包括性别、大概长相、瞳孔颜色、面部表情、穿搭、身材、肤色、背景、天气等。
反向提示词,将不好的或者不想要的东西排除在外例如:bad face,bad eyes,bad mouth,miss fingers, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality,等等
生成批次:可以选择一次生成多少张
face editor:勾选可以避免生成五官不端正的图片
以上参数,可以根据自己测试多次,来生成符合自己预期的图片
以下是我测试使用的Prompt:
masterpiece,best quality,official art,extremely detailed CG unity 8k wallpaper, day, original, girl, long hair, curly_hair, hair bow, grin, brown eyes, medium breasts, pleated_skirt, collared shirt , black kneehighs, high heels, arms behind head,
Negatice Prompt:nsfw, lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, bad feet, bad face,miss face,
下列图片使用的模型:lofi_V2pre.satetensors
部分实用模型我的百度网盘
更多模型下载
模型存放目录:
(base) [root@DevonL Stable-diffusion]# pwd
/usr/local/src/git/stable-diffusion-webui/models/Stable-diffusion
下图使用的模型:majicmixRealistic_v6.safetensors
Prompt:best quality, masterpiece, (photorealistic:1.4), 1girl, light smile, shirt with collars, waist up, dramatic lighting, from below
Negative prompt:nsfw, ng_deepnegative_v1_75t,badhandv4, (worst quality:2), (low quality:2), (normal quality:2), lowres,watermark, monochrome
Sampling method:Euler
Sampling steps:30
Hires.fix:enable
Upscaler:Latent
Hires steps:30
Denoising strengrh:0.5
CFG Scale:7
Seed:3698311310
Face Editor:Eanbled
Clip skip:2
报错:
Command: "git" -C "/usr/local/src/git/stable-diffusion-webui/repositories/stable-diffusion-stability-ai" rev-parse HEAD
[root@DevonL src]# vim /usr/local/src/git/stable-diffusion-webui/modules/launch_utils.py
:%s/-C/--exec-path/g
解决无法远程访问问题 [root@DevonL ~]# vim /usr/local/src/stable-diffusion-webui/webui.py 75行 if cmd_opts.server_name: server_name = cmd_opts.server_name else: server_name = "0.0.0.0" if cmd_opts.listen else None 改: if cmd_opts.server_name: server_name = cmd_opts.server_name else: server_name = "0.0.0.0" 362行 api.launch(server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1", port=cmd_opts.port if cmd_opts.port else 7861) 改: api.launch(server_name=server_name if cmd_opts.listen else "0.0.0.0", port=cmd_opts.port if cmd_opts.port else 7861)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。