


AI绘画幻觉文字生成教程
本次教程使用Stable Diffusion WebUI
的ControlNet
插件,教大家如何在原有图像上通过服饰或光影来生成幻觉文字效果。
目前主流的文字生成有两种方式,一种是光影(control_v1p_sd15_illumination
),另一种是通过服饰(control_v1p_sd15_brightness
)生成,本文教你如何使用control_v1p_sd15_brightness
进行图像绘制,下一节讲解control_v1p_sd15_illumination
模型。
前置条件
在执行项目安装之前,必须确保你的系统内已经安装部署Stable Diffusion WebUI
和ControlNet
插件,以下是关于相关内容的教程,如果有不明白地方可以自行查阅。
模型相关
模型下载
本文中所用到的所有模型文件如下:
- control_v1p_sd15_brightness.safetensors
- control_v1p_sd15_brightness.yaml
官方下载
如果你的魔法环境没有问题,那么可以自行前往官方模型仓库下载。
模型的官方下载地址:ioclab/ioc-controlnet · Hugging Face
网盘下载
关于此项目可能用到的所有模型,本站已为您下载并整理好。如果你不方便通过官网下载,可以使用本站所提供的网盘下载地址。
模型安装
将下载完成的模型,按照如下结构和路径位置进行存放:
.\stable-diffusion-webui\extensions\sd-webui-controlnet\models\control_v1p_sd15_brightness.yaml .\stable-diffusion-webui\extensions\sd-webui-controlnet\models\control_v1p_sd15_brightness.safetensors
准备工作
示例图像
关于Prompt方面,站长已经贴了出来,大家使用的时候可以自己调节部分参数。
best quality, ultra high res, (photorealistic:1.4), 1 girl, (ulzzang-6500:1.0), (style-keta:0.8) Negative prompt: paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, (outdoor:1.6), bad anatomy, large breast, nsfw Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: -1, Size: 500x800, Model hash: 7234b76e42, Model: chilloutmix_Ni, ControlNet 0: "preprocessor: invert (from white bg & black line), model: control_v1p_sd15_brightness [5f6aa6ed], weight: 0.4, starting/ending: (0.1, 0.8), resize mode: Crop and Resize, pixel perfect: True, control mode: Balanced, preprocessor params: (512, 100, 200)", Version: v1.5.1
下面这几张是随意生成的,方便我们后续对比一起加入ControlNet
引导之后的效果对比。



素材准备
在我们开始设置关于文字效果的ControlNet
之前,我们还需要准备一张文字图像,用来控制生成效果。
这是用Photoshop随意制作的,没有任何技巧,字体随意,大小随意,站长这里使用的分辨率为500
*800
。

生成教程
ControlNet
我们此时可以设置ControlNet
的相关内容了,这部分还是比较简单的,只需要加载模型,设置三个参数即可。
- 启用
ControlNet
- 启用
完美像素模式
- 启用
允许预览
- 上传
文字素材图像
- 预处理器:
invert(白底黑线反色)
- 模型:
control_v1p_sd15_brightness
- 控制权重:
0.4
- 文字素材图占有图像生成的权限,数值越大,文字越清晰。
- 引导介入时机:
0.1
- 这个数值最大为1,最小为0,代表百分比。这里的0.1也是最大数值1的10%。
- 假如我们的迭代步数为100次,也就是计算100次才会完成图像绘制,那么这里填写为0.1之后,代表在图像生成的第10步时,该文字素材将会参与图像生成。
- 引导终止时机:
0.8
- 计算方式与上面是一致的,只不过该参数代表的是什么时候结束,0.8就代表图像计算完成80%之后,该文字素材不再参数绘制引导。
- 在文字素材图像没有参与绘制的过程中,全部由AI自由发挥。
以下是设置的完整界面:

先随便生成几张图像看看效果:



我们会发现,人物变黑了,文字在脸上的效果也极差,所以我们素材图中的文字,要尽量靠下一点,尽量不要触及面部的位置,否则脸将极其难看。
以下是站长将文字下移之后,重新生成的图像。




我们还会发现一个问题,那就是文字很白,人物很黑,这是怎么造成的?
目前我们的ControlNet
设置中,选择的预处理器
为invert(白底黑线反色)
,我们的文字素材图是白底黑字,但通过这样的预处理设置之后,我们的文字会自动变为白色,底色变为黑色,这就是颜色反转,所以生成后的图像在人物的衣服上非常明亮,人却都是古铜的肤色。
反转颜色
下面站长尝试将预处理器
设置为无
,其它参数不做任何更改,以下是生成的案例。



出现新问题,文字太明显了?我们可以通过调整ControlNet
的控制权重数值来让文字的表现进行更改。







经过对比我们可以发现,控制权重的大小直接影响了文字显示的着色程度。具体是否开启颜色反转,还有控制数值的大小应该是多少,大家可以根据自己的需求去调节。
下面是站长生成的,个人认为还不错的图像效果。



服装文字
我们目前很多文字写出来的位置是不可控的,如果我们只希望文字出现在衣服上呢?
首先我们生成一张图像,然后记录种子,将该图像保存,放到Photoshop内在当前图像的基础上摆放文字,然后删除角色,将文字图片导出放置到ControlNet
内。
best quality, ultra high res, (photorealistic:1.4), 1 girl, (ulzzang-6500:1.0), (style-keta:0.8),Indoors, dimly lit, Negative prompt: paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, (outdoor:1.6), bad anatomy, large breast, nsfw Steps: 20, Sampler: DPM++ SDE Karras, CFG scale: 7, Seed: 1642015059, Size: 500x800, Model hash: 7234b76e42, Model: chilloutmix_Ni, ControlNet 0: "preprocessor: invert (from white bg & black line), model: control_v1p_sd15_brightness [5f6aa6ed], weight: 0.25, starting/ending: (0.1, 0.8), resize mode: Crop and Resize, pixel perfect: True, control mode: Balanced, preprocessor params: (512, 100, 200)", Version: v1.5.1





总结
好啦,今天就讲到这里吧,剩下的,大家自己摸索吧。
最近家务事太多了,耽误了很多技术的即使更新问题,唉。
下一期,光影文字技术正在写。
评论 (0)