# 前言

最近结课了,使用真的闲得无聊,看到 AI 绘画满天飞,虽然不怎么感兴趣,但是还是想部署一下玩玩

而且想到自己电脑配置不说比肩大神,但是至少 512x512 的轻度玩耍还是可以的

AI 绘画要求最高的就是 GPU 了,特别是显存,显存小是真的难受,我电脑 GPU 是移动端的 3060,6g 显存感觉还凑合

注:用 N 卡!!!

# 安装

这里我用的是 AUTOMATIC1111 仓库下的 Stable diffusion,感觉用起来挺方便的

项目地址:https://github.com/AUTOMATIC1111/stable-diffusion-webui

git clone 到本地即可,然后运行 webui-user.bat(当然如果是其他系统就运行相应的脚本就行)

运行后会下载各种依赖和其他文件

最大的依赖是 pytorch,有 2g 多,这个下载完了后面的就都是洒洒水了

注:安装时出现的各种问题绝大部分是裸连 Github 导致无法正常 clone 造成的,请换一个好的网络环境,必要时请上魔法

接着下载下载权重文件 sd-v1-4.ckpt

https://huggingface.co/CompVis/stable-diffusion-v-1-4-original

扔到 models/Stable-diffusion 目录下

其实我也不确定是否真的要下载,有空去测试一下(本人也在摸索阶段)

安装完可以在控制台找到一个链接,点击进入即可打开 Stable diffusion webui

# 切换简体中文

点击 Extension 选项卡,点击 Install from URL 子选项卡

将 git 仓库网址

https://github.com/dtlnor/stable-diffusion-webui-localization-zh_CN

粘贴进 URL 栏,点击 Install 进行安装

我这里点击后它提示我已经安装过,但是我之前是没装过,不过无所谓这时候已经装好了

重启 Web ui

接着在 Settings 选项卡中,找到 User interface 子选项

然后去页面最底部,找到 Localization ,找到在下拉选单中选中 zh_CN

没有的话就点击旁边的刷新按钮

点击 Apply settings 保存设置

最后点击 Reload UI 重启 webUI

# 优化

Stable diffusion webui 默认加载好像会把部分东西加载进 VRAM?反正启动完成还没开始绘图就占了我 3G 的 VRAM,

对于我这种只有 6G 显存的显卡太不友好了,然后我就发现可以在启动 bat 里的 set COMMANDLINE_ARGS= 后面添加 --lowvram 参数

这样启动的时候就显存占用就特别小了,给绘画留出了很多空余显存

还有一个插件,用来分块绘画的,就是专门为画高分辨率的画而设计的,下面是他的使用教程

【AI 科普】Stable Diffusion 显存不够用的拯救者插件

项目地址:https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111

当然你也可以看官方的介绍(有中文)

https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111/blob/main/README_CN.md

# 使用教程

这里我收集了一些使用的初级教程,大家可以参考,不过有点杂

# 安装使用篇

# 模型篇

# 提示词篇

# 进阶篇

# 小试牛刀

4K, best quality, masterpiece, Highly detailed, ultra-fine painting, Sci-fi, cowboy shot,(1boy:1.1), blush, school uniform, looking away
Negative prompt: mutated hands and fingers, deformed, bad anatomy, poorly drawn face, poorly drawn hands, missing limb, disconnected limbs. malformed hands
Steps: 24, Sampler: Euler a, CFG scale: 7, Seed: 66035402, Size: 512x512, Model hash: 1d1e459f9f, Model: anything-v4.5

4K, best quality, masterpiece, Highly detailed, ultra-fine painting, Sci-fi, cowboy shot,1boy, blush, school uniform, looking away
Negative prompt: mutated hands and fingers, deformed, bad anatomy, poorly drawn face, poorly drawn hands, missing limb, disconnected limbs. malformed hands
Steps: 24, Sampler: Euler a, CFG scale: 7, Seed: 66035402, Size: 512x512, Model hash: 1d1e459f9f, Model: anything-v4.5

(和上面的其实是一样的,只是 1boy 没加权重,就变成女孩了。。。不知道是不是这个模型训练女孩训练的多一些咳咳咳。。。

cyberpunk, slave, avengers, lipstick, zzz, silver hair, semi-rimless eyewear, summer dress, sneakers, Fairy wings, head tilt, back-to-back, rice paddy, Polaroid art, ((full body)),(helpless),tear, crying,(((((falling from the sky))))),((Weathering With You)),((falling)),((face towards the sky)),(hair flows upwards),((disheveled hair)),(1 girl), floating, beautiful detailed sky
Negative prompt: mutated hands and fingers, deformed, bad anatomy, poorly drawn face, poorly drawn hands, missing limb, disconnected limbs. malformed hands
Steps: 24, Sampler: Euler a, CFG scale: 7, Seed: 503677589, Size: 512x512, Model hash: 1d1e459f9f, Model: anything-v4.5

nvinkpunk , POV, muscle man, poet, lipstick, blush stickers, high ponytail, ear covers, gym_uniform, bandaged leg, dinosaur tail, own hands clasped, walk a dog, bar, (((ink))), ((watercolor)), (extremely detailed CG unity 8k wallpaper),(((masterpiece))), (((best quality))), ((ultra-detailed)), (best illustration),(best shadow), ((an extremely delicate and beautiful)),dynamic angle,floating, fairyland,dynamic angle,sea of flowers,beautiful detailed garden,wind,classic,spring, (detailed light),feather, nature, (sunlight), river, forest,(((floating palace))),((the best building)),beautiful and delicate water,(painting),(sketch),(bloom),(shine)
Negative prompt: mutated hands and fingers, deformed, bad anatomy, poorly drawn face, poorly drawn hands, missing limb, disconnected limbs. malformed hands
Steps: 24, Sampler: Euler a, CFG scale: 7, Seed: 3683048110, Size: 512x512, Model hash: 2182245415, Model: Inkpunk-Diffusion-v2

(best quality),(highly detailed),(((boy))),(((student))),
Steps: 24, Sampler: Euler a, CFG scale: 9, Seed: 1119134113, Size: 512x512, Model hash: 9aba26abdf, Model: Deliberate_v2

下面这几个忘记保存参数了,所以就只能将就着看喽

有成功的肯定也有翻车的,下面展示一下翻车案例🤣