惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
V
V2EX
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
MongoDB | Blog
MongoDB | Blog
P
Privacy International News Feed
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
美团技术团队
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
V
Visual Studio Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
K
Kaspersky official blog
S
Secure Thoughts
T
Tenable Blog
Security Latest
Security Latest
The Cloudflare Blog
S
Security @ Cisco Blogs
H
Heimdal Security Blog
aimingoo的专栏
aimingoo的专栏
TaoSecurity Blog
TaoSecurity Blog
Blog — PlanetScale
Blog — PlanetScale
Microsoft Security Blog
Microsoft Security Blog
Schneier on Security
Schneier on Security
Webroot Blog
Webroot Blog
G
Google Developers Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Scott Helme
Scott Helme
IT之家
IT之家
Latest news
Latest news
The Hacker News
The Hacker News
C
Check Point Blog
T
The Exploit Database - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
N
News | PayPal Newsroom
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
S
Security Affairs
S
Securelist
Google Online Security Blog
Google Online Security Blog
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
A
About on SuperTechFans

小明明s à domicile

Stable Diffusion高级教程 - Controlnet Stable Diffusion高级教程 - 图生图(img2img)模式 Stable Diffusion高级教程 - 微调模型 Stable Diffusion高级教程 - Script Stable Diffusion高级教程 - Extension Stable Diffusion高级教程 - Textual Inversion(Embedding) Stable Diffusion高级教程 - 如何使用Stable Diffusion? Stable Diffusion高级教程 - AIGC发展史和产品对比 关于本博客
Stable Diffusion高级教程 - VAE
2023-05-03 · via 小明明s à domicile

前言

这小节我们开始学习 Stable Diffusion 里面的 VAE,它的全称是变分自动编码器 (Variational Auto-Encoder),是机器学习中的一种人工神经网络结构。当然我们都不必了解的它的原理,只需要理解它是在 SD 模型的基础做微调的,类似于我们熟悉的滤镜,让生成的图片调整饱和度。

在页面上显示 VAE 设置

stable-diffusion-webui 默认页面并没有显示 VAE 设置部分,所以需要先设置一下。首先点击「Settings」,然后点左侧菜单的「User interface」这个 Tab,拉到下面有个选项叫做 Quicksettings list,在输入框里面添加,sd_vae,CLIP_stop_at_last_layers:

最后点击上面的「Apply settings」,在点「Reload UI」就会重新刷新页面,即可看到头部的 VAE 区域:

另外我也顺手打开了 Clip skip,在 C 站的图片参数中都有 Clip skip 选项,默认是 1,需要改成常用的 2,可以简单的理解这个值越高,AI 就会省略越多的分类细项。

下载 VAE 模型

目前我们还没有任何的 VAE 模型,需要下载再使用。VAE 主要是从 Huggingface 下载,而 C 站 VAE 比较少,并没有一个专门的过滤分类,只能通过搜索框输入 vae 过滤:

另外一个方式是看主模型下的提示,很多知名主模型里面会有 VAE 相关的内容,例如有打包 VAE 的模型 (自带的就不需要额外加了),或者在描述中建议你使用什么 VAE。

举个例子: RealDosMix 的描述中提到:

https://huggingface.co/stabilityai/sd-vae-ft-mse-original/blob/main/vae-ft-mse-840000-ema-pruned.ckpt https://huggingface.co/AIARTCHAN/aichan_blend/tree/main/vae Apply VAE. You will get better color results.

所以我们把这些 VAE 模型下载并把它放入到 models/VAE 目录下:

wget https://huggingface.co/stabilityai/sd-vae-ft-mse-original/resolve/main/vae-ft-mse-840000-ema-pruned.ckpt -O ~/workspace/stable-diffusion-webui/models/VAE/vae-ft-mse-840000-ema-pruned.ckpt
wget https://huggingface.co/AIARTCHAN/aichan_blend/resolve/main/vae/Anything-V3.0.vae.safetensors -O ~/workspace/stable-diffusion-webui/models/VAE/Anything-V3.0.vae.safetensors
wget "https://huggingface.co/AIARTCHAN/aichan_blend/resolve/main/vae/Berry's%20Mix.vae.safetensors" -O ~/workspace/stable-diffusion-webui/models/VAE/BerrysMix.vae.safetensors

下载好,然后点击 VAE 设置项右边的刷新按钮就可以看到这些模型了:

接着使用前面说的 X/Y/Z plot 脚本对比一下不加 VAE 和加了这三个 VAE 其中之一的效果:

所谓没有对比就没有伤害,对比明显可以感受到不加 VAE 图片优点灰蒙蒙的,不够鲜艳,另外是细节不够,而加了不同的 VAE 都有了更好的颜色效果,细节更全了 (微调)。

最后,注意不同的 VAE 适配的模型不同,也不是某个 VAE 可以用在任何模型下,否则可能会生成非常奇怪的图。

为什么 VAE 模型比较少?

我觉得主要的原因是很多软件已经实现了滤镜相关的功能,例如 PS、一些美颜 App、剪映等等。它们的效果更全更好,而且门槛很低。