Training-Free Layout Control with Cross-Attention Guidance 论文阅读
date
Nov 23, 2023
Last edited time
Nov 23, 2023 02:45 PM
status
Published
slug
Training-Free Layout Control with Cross-Attention Guidance 论文阅读
tags
DDPM
summary
type
Post
origin
Field
Plat
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2F2a661fb0-bcf7-428c-b3a1-0a61ffb0535d%2FUntitled.png?table=block&id=884d740f-5125-4fa4-b932-80795ba5757f&cache=v2)
Intro
当请求生成一个“一只猫左边的狗”的图像时,无法确保生成的对象之间的空间关系是否与期望的布局相匹配。为了解决这个问题,我们研究了文本到图像模型在生成过程中提取的注意力模式,并对其进行干预。尽管布局不能轻松地通过文本提示来控制,但实际上,我们可以通过直接干预激活模式来引导输出图像的重构方向。这种干预是基于用户指定的输入,例如边界框,我们称之为布局引导。为了实现这一目标,我们考虑并比较了两种替代策略:前向引导和反向引导。前向引导通过偏置交叉注意力层直接重新定位所需模式的激活,从而使模型能够通过迭代应用去噪步骤来融入引导信息。反向引导则使用反向传播来最小化能量,以更新网络中的激活,以匹配所需的布局。
Method
Cross-attention maps 可视化
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2F0a21dc03-6927-4105-965d-ba2eb55adee0%2FUntitled.png?table=block&id=6c53178a-3e73-4978-91a1-c25d2b7c73bd&cache=v2)
Forward Guidance
在Forward Guidance中,我们使用平滑窗口函数 来表示边界框B,该函数在框内部分等于一个正常常数 ,并在框外迅速衰减至零。我们对窗口函数进行缩放,使其总和为一()。接着,我们通过以下替换方式对注意力图 进行偏置处理:
Backward Guidance
我们引入能量函数来偏置注意力 :
通过反向传播计算损失的梯度,从而更新潜在变量。
Exp
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2F38ad6f5d-b386-46a4-9a61-4b2d8e06791a%2FUntitled.png?table=block&id=68559f1b-2322-476b-839d-f257d938e6ec&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2Fcbc47a93-5c3e-4c64-8208-97a5fe671391%2FUntitled.png?table=block&id=454a5647-66da-4d60-a00e-7670fde67282&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2F96997b20-6b4d-4598-8f76-c364fc4fd4ef%2FUntitled.png?table=block&id=6f078f39-13d9-4719-83d1-4d50b409cd7d&cache=v2)
![notion image](https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fd919c123-ae4b-49b3-af3c-0184fe33faac%2F1df8853c-9046-4782-9f96-f94d5aeff8b1%2FUntitled.png?table=block&id=093c2acd-55bd-4f04-85a2-4fb530fc5cc3&cache=v2)
这玩意在 Universal Guidance 里面也有,区别就是一个 guide x0,一个guide attention map.