1、前言
Stable Diffusion能够通过自定义的文字描述或图像来生成全新的图像,这项AI技术使得非绘图专业的普通人也能制作出大致想要的精美图像。
2、快速开始
2.1 下载stable-diffusion-webui
stable-diffusion-webui包含Stable Diffusion和用来操作它的网页界面。这一步先仅仅下载下来。
https://github.com/AUTOMATIC1111/stable-diffusion-webui
该页面下也有安装步骤。需要额外的软件Python,注意最好安装当前建议版本的Python。
2.2 安装Checkpoint Merge
Stable Diffusion(简称SD)需要知道我们想要的绘图风格、内容倾向等数据,因此我们将一些素材提供给它。Civitai提供了大量素材资源,我们可以在那里搜索下载。
Checkpoint Merge是指一类基础的模型数据,最终生成的图像也就跟这些模型数据的画风一致。例如ChilloutMix。
下载并存放在stable-diffusion-webui\models\Stable-diffusion目录下。
Windows用户执行stable-diffusion-webui目录下的webui.bat;Linux用户执行webui.sh。它会先自动下载一些必须文件。
我中途由于网络问题报了几个错误,重试几次就行了,完成后如下图所示:
按提升打开网页:http://127.0.0.1:7860/
2.3 安装插件sd_civitai_extension
此插件能帮助我们获取和显示我们在Civitai下载的资源的预览图。在页面中切换至Extensions标签,再切换至Install from URL子标签,输入地址:https://github.com/civitai/sd_civitai_extension
点击“Install”按钮,稍等片刻。待完成后点击左边的Installed子标签,可以看到sd_civitai_extension插件已经安装完毕,最后点击“Apply and restart UI”按钮,至此Stable Diffusion的最基础功能已安装完成,可以使用了。
先来个测试吧,切换至txt2img标签,在上面的Prompt输入框中输入想要图像的关键词或文字描述,例如:The girl is flying in the sky
。下面Negative prompt输入框可以输入不想出现的关键词。然后点“Generate”按钮,等待片刻即可生成图像。
哈哈哈,至少说明Stable Diffusion已经正常运行了。
3、更多设置
3.1 安装LoRA模型
LoRA模型是对基础模型数据的微调,可以其像LoRA中的人物。下载时注意页面右边的Type是LORA。例如Asuna LoRa。
下载并存放在stable-diffusion-webui\models\lora目录下。然后点击Generate按钮下的这个图标。
切换至下面的Lora标签,选择安装的LoRA,这时上面的关键词输入框中会出现<lora:asunaLora_asuna:1>
。说明已经选择成功了,权重默认为1,这个值通常太高了,应该改为Lora下载页面中的建议值,例如Asuna LoRA的建议值为0.6。
我们继续使用The girl is flying in the sky.来生成图像,并添加关键词asuna来触发这个LoRA。最终Prompt语句为:The girl is flying in the sky.asuna.<lora:asunaLora_asuna:0.6>
效果……呃……还可以吧。因为我们的基础模型资源(Checkpoint Merge)是真人类型,而这个LoRA却使用的动漫风格,所以最终融合的不太好。我们可以下载一个动漫风格的Checkpoint Merge,例如AbyssOrangeMix2,然后再次生成。
3.2 安装界面翻译插件sd-webui-bilingual-localization
虽然大部分英文选项也能看懂,但有中文还是更棒的。在页面中切换至Extensions标签,再切换至Available子标签,点击“Load from”按钮来获取最新的插件列表。找到sd-webui-bilingual-localization插件,点击右边的Install按钮进行安装。或者在Install from URL子标签里输入插件地址https://github.com/journey-ad/sd-webui-bilingual-localization来安装。之后切换到Installed子标签,点击“Apply and restart UI”按钮。
接着下载中文翻译文件,在https://gist.github.com/journey-ad/d98ed173321658be6e51f752d6e6163c中下载json文件,并存放至stable-diffusion-webui\localizations目录下。
在页面在Settings -> Bilingual Localization中选择刚才下载的翻译文件,依次点击Apply settings和Reload UI按钮。
现在界面就是中英双语啦~
3.3 提示词
一张图像是随机生成的,但我们通过提示词(Prompt)和反向提示词(Negative prompt)来获取和限制其“脑洞”。网上有很多分享,这里转载一个。
提示词:
1girl, solo focus, tomboy, pale skin, medium breasts, wide hips, slim, toned, delicate, grey multicolored hair, very long hair, long ponytail, yellow eyes, sweat, tall female, black shirt, white coat, black legwear, accessories, earbuds, wristwatch, piercing, cross necklace, stylish sneakers, holding cup, outdoors, cold, ((rain)), beautiful view, city view in the distance, seaside, mountainous horizon, sitting on bus stop, gloom\(expression\), sad, looking away, overcast, cloudy, dawn, {correct posing}, {detailed background}, {detailed body}, {correct body anatomy}, {extremely beautiful and delicate anime face and eyes}, {from the side:0.5}, {realistic:0.8},
1girl,独奏焦点,假小子,苍白的皮肤,中等乳房,宽臀部,苗条,色调,精致,灰色多彩的头发,非常长的头发,长马尾辫,黄色的眼睛,汗水,高女性,黑衬衫,白色外套,黑legwear,配件,耳塞,手表,穿孔,十字架项链,时尚的运动鞋,拿着杯子,户外,冷,((雨)),美景,远处的城景,海滨,山的地平线,坐在车站,阴沉沉的\(表情\),悲伤,转移视线,阴,多云,黎明,{正确的姿势},{详细的背景},{详细的身体},{正确的身体解剖},{极其美丽精致的动漫脸和眼睛},{从侧面看:0. 5},{逼真:0. 8},
反向提示词:
nsfw, (worst quality, low quality:1.4), (lip, nose, tooth, rouge, lipstick, eyeshadow:1.4), ( jpeg artifacts:1.4), (depth of field, bokeh, blurry, film grain, chromatic aberration, lens flare:1.0), (1boy, abs, muscular, rib:1.0), greyscale, monochrome, dusty sunbeams, trembling, motion lines, motion blur, emphasis lines, text, title, logo, signature, (low quality, worst quality:1.4), (bad anatomy), (inaccurate limb:1.2),bad composition, inaccurate eyes, extra digit,fewer digits,(extra arms:1.2), bad fingers, wrong expression, bad hands, incorrect anatomy hands, bad crop, cropped. terrible anatomy. text. watermark, bad nipples, lowres, no nipples, unrealistic anatomy, clipping boobs, clipping arms, bad arms, bad anatomy, bad hands, mutated hand, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry, artist name, out of focus, glowing eyes, (((multiple views))), (((bad proportions))), (((multiple legs))), (((multiple arms))), bad_prompt, wrong color, (worst quality:2.0), (low quality:2.0), inaccurate limb, 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, artist name, tall, (painting by bad-artist-anime:0.9), (painting by bad-artist:0.9), bad-prompt:0.5, watermark, text, error, blurry, jpeg artifacts, cropped, normal quality, jpeg artifacts, signature, watermark, username, artist name, (worst quality, low quality:1.4), bad anatomy, low quality lowres, low quality lowres quality lowres monochrome sketch rough graffiti, low quality lowres very ugly fat obesity scar, low quality lowres chibi, low quality lowres poorly drawn bad anatomy, low quality lowres graffiti unbecoming colorfully, low quality lowres incoherent background, low quality lowres long body, low quality lowres duplicate comparison, low quality lowres sketch retro_artstyle doujinshi, low quality lowres sketch, low quality lowres text font ui error missing digit blurry, low quality lowres JPEG artifacts signature hazy bleary, low quality lowres monochrome parody meme, low quality lowres historical picture, low quality lowres disfigured mutated malformed twisted human body, low quality lowres futanari tranny, low quality lowres tentacle skeleton, low quality lowres vomit suicide death dirty, (nipples:1.2), lowres, bad anatomy, bad hands, text, error, missing finger, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry