FateZero: Fusing Attentions for Zero-shot Text-based Video Editing
motivation: 使用预训练的t2i模型实现zero-shot 、text-based 视频编辑
contribution: 在attention上修改
在反转过程中的每一步,存储self-attention与cross-attention maps(目的:能够在随后的ddim pipeline的去噪步骤中替换它们);
将自我注意块改造为时空注意块,目的:使外观更加一致
Attention blended block
归纳总结:
- 做的什么任务,要达到什么目的,输入是什么,输出是什么?
zero-shot text-based video editing,输入为原视频(及源prompt),编辑prompt,输出编辑后的图像 - 通过什么方式实现的编辑或者生成,了解不同的方式有什么特点
DDIM Inversion
DDIM:
z
t
−
1
=
α
t
−
1
z
t
−
1
−
α
t
ε
θ
α
t
+
1
−
α
t
−
1
ε
θ
,
(
2
)
z_{t-1}=\sqrt{\alpha_{t-1}}\frac{z_{t}-\sqrt{1-\alpha_{t}}\varepsilon_{\theta}}{\sqrt{\alpha_{t}}}+\sqrt{1-\alpha_{t-1}}\varepsilon_{\theta},\quad(2)
zt−1=αt−1αtzt−1−αtεθ+1−αt−1εθ,(2)
DDIM Inversion:
z
^
t
=
α
t
z
^
t
−
1
−
1
−
α
t
−
1
ε
θ
α
t
−
1
+
1
−
α
t
ε
θ
.
(
3
)
\hat z_t=\sqrt{\alpha_t}\frac{\hat z_{t-1}-\sqrt{1-\alpha_{t-1}}\varepsilon_\theta}{\sqrt{\alpha_{t-1}}}+\sqrt{1-\alpha_t}\varepsilon_\theta.\quad(3)
z^t=αtαt−1z^t−1−1−αt−1εθ+1−αtεθ.(3)
之前的工作:edit attention与DDIM重建过程中的attention融合
fatezero:edit attention与DDIM inversion过程中存储的attention融合
FateZero Video Editing
Inversion Attention Fusion
baseline是什么? style and attribute editing(stable diffusion v1.4),shape editing(Tune a video)
如何fusion?
an adaptive spatial mask 如何获得?
首先将源视频编码的
z
0
z_{0}
z0输入DDIM inversion pipeline,得到
z
T
z_{T}
zT,条件为
p
s
r
c
p_{src}
psrc(源视频prompt)
将
z
T
z_{T}
zT逐步去噪,得到
z
^
0
\hat{z}_0
z^0,以
p
e
d
i
t
p_{edit}
pedit为条件
在DDIM inversion过程中,存储self-attention map s t s r c s_t^{src} stsrc 与 cross attention map c t s r c c_t^{src} ctsrc
在去噪过程中,未编辑部分的cross attention部分 c t e d i t c_t^{edit} ctedit用原始cross attention c t s r c c_t^{src} ctsrc 替换(未编辑的部分保持原始的attention)用一种 an adaptive spatial mask(自适应的空间掩码,由 c t s r c c_t^{src} ctsrc获得)融合 s t s r c s_t^{src} stsrc与 s t e d i t s_t^{edit} stedit
Attention Map Blended
去掉修改后的self-attention:直接用
s
s
r
c
s^{src}
ssrc替换
s
e
d
i
t
s^{edit}
sedit
保留修改后的self-attention:保留
s
e
d
i
t
s^{edit}
sedit
blended self-attention:
M
t
=
H
E
V
I
S
I
D
E
T
E
P
(
c
t
s
r
c
,
τ
)
,
(
6
)
s
t
f
u
s
e
d
=
M
t
⊙
s
t
s
d
i
t
+
(
1
−
M
t
)
⊙
s
t
s
r
c
.
(
7
)
\begin{gathered} M_t =\mathrm{~HEVISIDETEP}(c_t^{src},\tau), (6) \\ s_{t}^{\mathrm{fused}} =M_t\odot s_t^{\mathrm{sdit}}+(1-M_t)\odot s_t^{\mathrm{src}}. (7) \end{gathered}
Mt= HEVISIDETEP(ctsrc,τ),(6)stfused=Mt⊙stsdit+(1−Mt)⊙stsrc.(7)
mask由cross attention得到:对edit word的cross attention进行阈值处理
原因:cross attention提供图像的语义层
Spatial-Temporal Self-Attention
解决视频帧间不一致现象
将self-attention改为Spatial-Temporal Self-Attention(时空自注意力)
z
i
z_{i}
zi的Attention层实现为
Q
=
W
Q
z
i
,
K
=
W
K
[
z
i
;
z
w
]
,
V
=
W
V
[
z
i
;
z
w
]
,
(
8
)
Q=W^Q\mathbf{z}^i,K=W^K\left[\mathbf{z}^i;\mathbf{z}^{\mathbf{w}}\right],V=W^V\left[\mathbf{z}^i;\mathbf{z}^{\mathbf{w}}\right],(8)
Q=WQzi,K=WK[zi;zw],V=WV[zi;zw],(8)
[
⋅
]
[\cdot]
[⋅]指的是连接操作,只需要对中间帧进行warp操作(
z
w
=
z
R
o
u
n
d
[
n
2
]
\mathbf{z}^{\mathrm{w}}=z^{\mathrm{Round}[\frac{n}{2}]}
zw=zRound[2n])就足够进行属性和样式编辑
Shape-Aware Video Editing(形状感知视频编辑)
改变视频中特定物体的形状更具挑战性
ablation study
没有self-attention的融合,难以保留原视频的一些细节
没有spatial mask原始吉普车的结构会影响生成的保时捷汽车