系列文章目录
Stable Diffusion界面参数及模型使用
谷歌Colab云端部署Stable Diffusion 进行绘图
前言

近期,智能AI绘画以其低成本、高效率、多风格、易操作等特点爆火全网,对原画、平面设计等领域造成巨大冲击,据悉,众多公司(特别是游戏公司)已将AI绘画引进工作流程,更有甚者已经裁掉了公司一半的原画师。
借着AI绘画学习的热潮,笔者迫不及待想要体验一下号称业界最强的Stable Diffusion WebUI

一、Stable Diffusion是什么?
Stable Diffusion是一个AI 绘图软件 (开源模型),可本地部署,可切换多种模型,且新的模型和开源库每天都在更新发布,最重要的是免费,没有绘图次数限制。
二、安装前的准备
1.检查自己的电脑配置是否符合要求
电脑的显存至少2G以上
小tips:如何查看自己电脑显存大小:
在Windows【开始】点鼠标右键,选择【任务管理器(T)】,在【性能】一栏选择【GPU】查看“专用GPU内存”

2.下载安装Git
https://git-scm.com/


小tips:Git是一个免费的、开源的分布式版本控制系统
点击Git Bash Here可以打开Git终端
检查自己电脑有没有安装过Git:【Win+R】唤出【运行】,输入“cmd”,回车,在命令行里输入
如下图所示,出现版本号则说明安装过

3.下载安装Python

最好下载这个版本


注意要勾选此选项,将python添加到系统环境变量PATH中


因为笔者上学时安装过python,怕旧版本不支持Stable Diffusion,所以也借此机会更新一下版本,
检查有没有升级成功:【Win+R】唤出【运行】,输入“cmd”,回车,在命令行里输入
如下图所示,出现版本号,成功升级至3.10版本

三、下载stable-diffusion-webui仓库
https://github.com/AUTOMATIC1111/stable-diffusion-webui
在空间比较大的盘里新建一个文件夹,如下图名为【AI】的文件夹,然后在这个文件夹里点击鼠标右键,选择【Git Bash Here】打开Git终端

如下图所示,成功打开了一个Git终端

通过Git命令克隆下载代码
- git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
复制代码
出现问题:
OpenSSL SSL_read: Connection was reset, errno 10054
解决方法:
关闭git的https证书验证
- git config --global http.sslVerify false
复制代码 之后再次clone代码,成功!

同时可以看到文件夹里也下载好了

四、运行webui-user.bat
在上面下载好的文件夹里找到它,双击运行

下载中

出现新问题:提示pip更新?

解决方法:
升级pip命令,可以重新打开一个命令行,运行一次它提示的绿色命令(因为文件夹名称可能不同,所以这条命令因人而异)
- H:\AI\stable-diffusion-webui\venv\Scripts\python.exe -m pip install --upgrade pip
复制代码
之后再次重新打开webui-user.bat
因为笔者在安装过程中没有使用魔法上网,所以在下载过程中出现了gfpgan、clip、open clip没有安装成功的提示,还是国内的网络环境的原因,解决方法:
编辑stable-diffusion-webui目录里的launch.py文件
比如卡在了gfpgan,就找到run_pip(f"install {gfpgan_package}“, “gfpgan”)所在行,如下图launch.py文件的第263行,把它改为run_pip(f"install -i https://pypi.douban.com/simple/ {gfpgan_package}”, “gfpgan”),修改后保存关闭,走国内的镜像源( -i https://pypi.douban.com/simple/),提高下载速度
- run_pip(f"install -i https://pypi.douban.com/simple/ {gfpgan_package}", "gfpgan")
复制代码
之后保存launch.py文件,再次打开webui-user.bat
(每次下载出现问题,就修改launch.py文件里的对应内容,比如clip出问题就把launch.py文件里的run_pip(f"install {clip_package}“, “clip”)改为run_pip(f"install -i https://pypi.douban.com/simple/ {clip_package}”, “clip”)),gfpgan、clip、open clip都是一样的操作,如此反复(修改launch.py、关闭命令行、重新打开webui-user.bat)
如果还是卡住不动的话,在launch.py文件里找到prepare_environment()这部分,在对应的https://github.com/前面加上https://github.moeyy.xyz/
通过代理的方式加速git

经过多次修改、关闭、重启,最后终于走到了Web UI这里

一切顺利的话,接下来就要下载一个3.97G的大东西,中间如果卡住,还是关闭命令行、重新打开webui-user.bat


经过一段时间的等待,进度条终于填满了,也出现了我们最希望看到的内容

表示本地电脑启动了一个服务,端口是127.0.0.1:7860
把http://127.0.0.1:7860复制到浏览器中打开,进入Stable Diffusion界面

用基础模型生成一个小女孩试试,生成速度取决于电脑配置

emmm,流露出一种诡异的美
再生成一个老虎看看

总结
通过走国内镜像的方式来提高下载的速度和稳定性。
下一篇博客拟介绍Stable Diffusion的界面参数,尝试一下其他模型。
完结散花,感谢观看!
来源:https://blog.csdn.net/weixin_43905975/article/details/129988104
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |