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

推荐订阅源

W
WeLiveSecurity
T
Tenable Blog
Project Zero
Project Zero
C
Cybersecurity and Infrastructure Security Agency CISA
T
The Exploit Database - CXSecurity.com
P
Palo Alto Networks Blog
S
Schneier on Security
Scott Helme
Scott Helme
S
Securelist
Know Your Adversary
Know Your Adversary
Vercel News
Vercel News
IT之家
IT之家
V
V2EX
F
Fortinet All Blogs
Simon Willison's Weblog
Simon Willison's Weblog
K
Kaspersky official blog
博客园_首页
T
Tailwind CSS Blog
The GitHub Blog
The GitHub Blog
Spread Privacy
Spread Privacy
Microsoft Security Blog
Microsoft Security Blog
Cisco Talos Blog
Cisco Talos Blog
The Register - Security
The Register - Security
有赞技术团队
有赞技术团队
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
Hugging Face - Blog
Hugging Face - Blog
博客园 - 三生石上(FineUI控件)
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
CERT Recently Published Vulnerability Notes
S
SegmentFault 最新的问题
AWS News Blog
AWS News Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
P
Proofpoint News Feed
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost

小明明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、剪映等等。它们的效果更全更好,而且门槛很低。