图像生成:扩散模型
参考资料:
CVPR 2023 Tutorial: Denoising Diffusion Models: A Generative Learning Big Bang
CVPR 2024 Tutorial: Diffusion-based Video Generative Models
【较真系列】讲人话- Diffusion Model 全解(原理+代码+公式)
Denoising Diffusion Models 在图像中的应用
Diffusion Model 的结构
-
基于 U-Net 结构:被广泛用于 text-to-image Diffusion Model 中
- Imagen
- Stable Diffusion
- eDiff-I
-
基于 Transformer 结构:将图像分割为 patch 后作为 tokens 输入至 Transformer 中
- Scalable Diffusion Models with Transformers
- One Transformer Fits All Distributions in Multi-Modal Diffusion at Scale
- Simple Diffusion: End-to-end Diffusion for High Resolution Images
使用 Diffusion Model 对图像进行编辑和定制
目前有三种常见的引导(Guidance)方法:
- RGB Pixel Guidance
- Text Guidance
- Reference Image Guidance
RGB Pixel Guidance
ICLR 2022, SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations
Given an input image with user guide in a form of manipulating RGB pixels, SDEdit first adds noise to the input, then subsequently denoises the resulting image through the SDE prior to increase its realism.
通过用户在原图上给出一些引导,比如 RGB 像素的涂鸦(stroke painting),甚至可以不给定原图,直接纯手工绘制一个涂鸦画作为输入,模型首先对输入添加噪声,最后通过随机微分方程的先验增加图片的真实性,最终根据输入的带有引导信息的图像生成对应的结果。
Synthesizing images from strokes with SDEdit. The blue dots illustrate the editing process of our method. The green and blue contour plots represent the distributions of images and stroke paintings, respectively. Given a stroke painting, we first perturb it with Gaussian noise and progressively remove the noise by simulating the reverse SDE. This process gradually projects an unrealistic stroke painting to the manifold of natural images.
下图中的蓝点代表本文的编辑过程,绿色分布代表真实图像的分布, 蓝色分布代表 stroke paintings 的分布。
当模型首先被输入 stroke painting 后,使用高斯噪声进行扰动,然后通过模拟反向随机微分方程逐步移除噪声。这一过程逐步将不真实的 stroke painting 投影到自然、真实图像的分布中。
Text Guidance
ICLR 2023, DiffEdit: Diffusion-based semantic image editing with mask guidance
论文引入一个掩码生成模块,该模块确定图像的哪一部分应该被编辑,然后只对掩码部分执行基于文本的扩散。
首先用户输入参考图像以及两个查询文本和参考文本,查询文本 Query 是参考图像的标题或用于描述图像,参考文本 R 用于描述想要替换的效果。
掩码生成模块首先为输入图像添加噪声,并进行两次去噪,一次通过参考文本 R 进行,一次通过查询文本 Q 进行,并根据去噪结果的差异推导出参考图像中的掩码区域。
CVPR 2023, Imagic: Text-Based Real Image Editing with Diffusion Models
模型接受真实图像(参考图像)和目标图像文本描述 作为输入。
-
模型首先对目标文本进行编码,得到初始嵌入表示 ,然后优化 对原始图像进行重构,得到优化后的目标文本嵌入表示 。
目标文本首先通过一个文本编码器,该编码器输出其对应的文本嵌入 ,其中 是给定目标文本中的 token 数量,而 是 token 的嵌入维度。固定生成扩散模型 的参数,并使用重构损失来优化目标文本嵌入 :
其中 ,