还是先做个基本观点的先容,什么是Stable Diffusion?
Stable Diffusion是一种基于潜在扩散的机器学习模型,能够将文本描述转化为高质量的图像。好了,不多说了,多说就专业了,也听不懂,直接装起来玩吧。
在支配之前,我假设你的centos已经安装了nvidia驱动和docker,不会的自行搜索。得空单独写一篇。
首先拉取一个通用的系统镜像(不想从头搞镜像可以直接用我的,后面有,但是代码还是要拉,映射到指定目录。):
docker pull pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel
接着去github把stable diffusion的代码拉下来:
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
代码拉下来之后,找到modules目录下的launch_utils.py文件,打开,找到所有github.com的地址,在前面加上“https://github.moeyy.xyz”,这是用来加速的,不然安装的时候速率比较慢,当然你自己有代理工具就用你自己的办法。
接着还是这个文件,找到所有安装python模块的地方,加上海内的镜像源,也是为了加速,不然安装跑半天,蛋疼的很,如下所示:
https://pypi.douban.com/simple/
自己看着点,有好几个呢,别漏了。
接着是把根本依赖下载下来,那个网站也是海内没办法访问的,须要下载的文件很大,就更难了,本来想给大家放网盘的,结果看有网友已经分享了,地址如下:
https://pan.baidu.com/s/1wWGhkLfK7a4Q3CPywhgicg?pwd=ewxd
下载下来后,在项目根目录下新建openai目录,然后塞进去即可。如下图所示:
这样我们的准备事情就搞完了,把代码映射到容器里,开始构建:
docker run -itd --name stable-diffusion-webui -v /root/stable-diffusion:/data/stable-diffusion-webui \--gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all \-p 7860:7860 pytorch/pytorch:2.0.1-cuda11.7-cudnn8-devel
然后进入容器,实行如下命令安装依赖:
docker exec -it stable-diffusion-webui bashapt install wget git python3 python3-venv libgl1 libglib2.0-0cd /data #进入项目目录pip install -r requirements.txt
虽然加了代理和换了镜像源,还是须要等待一段韶光的,等进度条走完,就大功告成了,当然大家如果
registry.cn-hangzhou.aliyuncs.com/laughstorm/stable-diffusion-webui:v2
接着,我们删除之前的镜像,用新打出来的镜像启动容器,并且启动做事端点:
docker run -itd --name stable-diffusion-webui -v /root/stable-diffusion:/data/stable-diffusion-webui \--gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all \-p 7860:7860 registry.cn-hangzhou.aliyuncs.com/laughstorm/stable-diffusion-webui:v2 /data/stable-diffusion-webui/webui.sh --xformers --listen
做事暴露在机器的7860端口,打开浏览器访问,Duang!
你们出来的界面没我这么好看的,由于我装了主题插件,主题叫sd-webui-lobe-theme,下载地址如下:
https://github.com/lobehub/sd-webui-lobe-theme.git
下载下来后,放到extensions目录下,然后重启下容器就可以了。
然后大家想要下载模型,可以去https://civitai.com。末了再秀两张作品吧。
提示词干系信息如下:
beautifuldetailedflower,beautifuldetailedeyes,hyperdetailed,flower,hyperquality,eyes,flowerandhairissamecolor,beautifulycolor,face,{{{{{herhairisbecomingflower,flower,hair,flower,butterfly,}}}}},{{{{1girl}}}}kawaii,{{{highdetails,highquality}}},{{{backlight}}},{{hairandclothesisflower}},{{{upperbody}}},highquality,hairwithbody,webbeddress,upperbody,flowerleg,flowerhands,bodywithflower,{{flowerwithclothes}},dresswithflower,lightparticles,blackbackground,{{{{Hairwithflower}}}},smallbreastwithflower,bighairwithflower,{{floatinghairwithflower,floating}}1girl,smallbreast,marblingwithhairandclothes,lookingatviewer,{{original}},{{armdown}},{{papercutting}},blackbackground,flowerforground,{{hairwithflower}},{{{{{highres}}}},}hairwithflower,hairwithflower,hair,wavyhair,diffusionlighting,abstract,Butterflywithbody,flowerwithhair,herhairisflower,bigtopsleeves,floating,Negative prompt: BadDream,FastNegativeV2,easynegative,Steps: 20, Sampler: DPM++ 2M Karras, CFG scale: 7, Seed: 3789752464, Size: 768x768, Model hash: ac68270450, Model: real_beautifulRealistic_brav5, Version: 1.7.0