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

推荐订阅源

L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
博客园 - 司徒正美
罗磊的独立博客
D
Docker
Last Week in AI
Last Week in AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
V2EX
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 叶小钗
B
Blog RSS Feed
A
About on SuperTechFans
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
P
Proofpoint News Feed

StudyingLover's Blog

Diffusion Policy笔记 rwkv笔记 act笔记 nanovllm-block_manager opencode多智能体 nanobot-pre-train nanobot-rl nanobot-sft nanobot-checkpoint_manager nanobot-gpt nanobot-mid-train Vision Mamba (Vim)笔记 BPE演示 最后一遍学习Transformer YOLOv5 目标检测笔记 下载根服务器解析记录 Dynaseal A Backend-Controlled LLM API Key Distribution Scheme with Constrained Invocation Parameters 判断链表有环 王道25数据结构勘误 关于perplexity的open-sourcing-r1-1776 AI为什么不像人类一样进行多轮对话 新博客改造日记和功能测试 linuxqq只显示登陆背景图 数字设计和计算机体系结构(机械工业出版社)勘误(自制) Dynaseal:面向未来端侧llm agent的llm api key分发机制 A Definitive Guide to Markdown Style This post is using MDX, Where you can embed JSX and Astro components RT-Patch学习 pydantic实现的LLM ReAct fastapi 和 uvicorn 设置监听 ipv6
StableDiffusion笔记
About the Author StudyingLover · 2023-05-29 · via StudyingLover's Blog

Stable Diffusion 是一个图像生成方法,由 Stability AI and Runway 在LDM1 的基础上提出。在GitHub有很多他的实现和应用234 ,其中2 是最早的实现版本,3 是V2版本,由 Stability AI 完成。

整体结构

flowchart TD

subgraph Input-noisy
Random-seed --> latent-Gaussian-noise 
end

subgraph Input-prompt
prompt --> TextEncoder --> TextEmbaddings
end

latent-Gaussian-noise -->Unet{Unet-with-MultiAttention}
TextEmbaddings-->Unet

Unet --> predict-noisy --sampling-steps-->Unet
predict-noisy --> Decoder --> Image 

在一开始,StableDiffusion会通过一个随机数种子生成一张在隐空间下的随机噪声,同时通过一个文本编码器对输入的prompt进行编码,生成一个文本向量。随机噪声和文本向量会一块送入Unet,经过DDPM的步骤得到一张隐空间下的图片,通过一个解码器得到完整的图片。这里的Unet做出了改进,中间加入了交叉注意力机制。

Unet-with-MultiAttention

Unet-with-MultiAttention 图源medium.com 图中Switch用于在不同的输入之间调整。

  • 文本数据通过一个文本编码器(一般是CLIP的文本编码器)将文本转换为向量,投影到Unet上
  • 图像,语义图,表示等直接送入Unet

反向扩散过程中输入的文本向量和隐空间下的噪声图片需要经过 tt轮的Unet网络,每一轮预测一个噪声,噪声图减去这个噪声,得到的图片继续送入Unet进行下一轮

参考文献

Footnotes

  1. Rombach, R., Blattmann, A., Lorenz, D., Esser, P., & Ommer, B. (2022). High-Resolution Image Synthesis with Latent Diffusion Models. 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Presented at the 2022 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA. https://doi.org/10.1109/cvpr52688.2022.01042

  2. CompVis. (n.d.). GitHub - CompVis/stable-diffusion: A latent text-to-image diffusion model. GitHub. Retrieved May 29, 2023, from https://github.com/CompVis/stable-diffusion ↩ ↩2

  3. Stability-AI. (n.d.). GitHub - Stability-AI/stablediffusion: High-Resolution image synthesis with latent diffusion models. GitHub. Retrieved May 29, 2023, from https://github.com/Stability-AI/stablediffusion ↩ ↩2

  4. AUTOMATIC1111. (n.d.). GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UI. GitHub. Retrieved May 29, 2023, from https://github.com/automatic1111/stable-diffusion-webui