简介
paper:Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking
code:594422814/TransformerTrack
盼着盼着它来了!这篇论文将Transfomer
引入了单目标跟踪任务中,且取得了很好的效果。这篇论文提供了一个基于Transfomer
的中间模块,通过该中间模块可以显著提升提取的特征质量。
主要内容
不同于原始的Transfomrer
,这篇论文将encoder
和decoder
两部分分开,其中encoder
部分对backbone
提取的Template Feature
通过Attention
进行特征加强。而Search Feature
则经由decoder
进行处理。
Transformer Encoder
输入到encoder
的是一系列template feature
,即
T
=
(
T
1
,
⋯
,
T
n
)
∈
R
n
×
C
×
H
×
W
T=\left(\mathbf{T}_{1}, \cdots, \mathbf{T}_{n}\right) \in \mathbb{R}^{n \times C \times H \times W}
T=(T1,⋯,Tn)∈Rn×C×H×W ,为了便于计算作者将
T
T
T转换为
T
′
∈
R
N
T
×
C
T^{'} \in \mathbb{R}^{N_{T} \times C}
T′∈RNT×C,其中
N
T
=
n
×
H
×
W
N_{T}=n \times H \times W
NT=n×H×W
最终对于encoder
部分可以表示为:
A T → T = Atten ( φ ( T ′ ) , φ ( T ′ ) ) ∈ R N T × N T \mathbf{A}_{\mathrm{T} \rightarrow \mathrm{T}}=\operatorname{Atten}\left(\varphi\left(\mathbf{T}^{\prime}\right), \varphi\left(\mathbf{T}^{\prime}\right)\right) \in \mathbb{R}^{N_{T} \times N_{T}} AT→T=Atten(φ(T′),φ(T′))∈RNT×NT
T ^ = Ins. Norm ( A T → T T ′ + T ′ ) \hat{\mathbf{T}}=\text { Ins. } \operatorname{Norm}\left(\mathbf{A}_{\mathrm{T} \rightarrow \mathrm{T}} \mathbf{T}^{\prime}+\mathbf{T}^{\prime}\right) T^= Ins. Norm(AT→TT′+T′)
where ϕ(·) is a 1 × 1 linear transformation that reduces the embedding
channel from C to C/4.
通过self-attention
,最终可以得到很高质量的template features
.
Thanks to the self-attention, multiple temporally diverse template features aggregate each other to generate high quality T ^ \hat{\mathbf{T}} T^
Transformer Decoder
首先同encoder
一样,decoder
的第一部分也是采用一个Self-Attention
的结构且与encoder
部分的Self-Attention
共享权重,这么做的目的是保证将Template Feature
和Search Feature
映射到同一特征空间中.
同encoder
中的处理一样,对于Search feature
,即
S
∈
R
C
×
H
×
W
S \in \mathbb{R}^{C \times H \times W}
S∈RC×H×W,同样reshape
为
S
′
∈
R
N
S
×
C
\mathbf{S}^{\prime} \in\ \mathbb{R}^{N_S \times C}
S′∈ RNS×C,则第一个Self-Attention
部分可以表示为:
S ^ = Ins. Norm ( A S → S S ′ + S ′ ) \hat{\mathbf{S}}=\text { Ins. } \operatorname{Norm}\left(\mathbf{A}_{\mathbf{S} \rightarrow \mathbf{S}} \mathbf{S}^{\prime}+\mathbf{S}^{\prime}\right) S^= Ins. Norm(AS→SS′+S′)
where A S → S = Atten ( φ ( S ′ ) , φ ( S ′ ) ) ∈ R N S × N S \mathbf{A}_{\mathbf{S} \rightarrow \mathbf{S}}=\operatorname{Atten}\left(\varphi\left(\mathbf{S}^{\prime}\right), \varphi\left(\mathbf{S}^{\prime}\right)\right) \in \mathbb{R}^{N_{S} \times N_{S}} AS→S=Atten(φ(S′),φ(S′))∈RNS×NS is the self-attention matrix of the search feature.
之后论文将decoder
划分为Feature Transformation
和Mask Transformation
.
Mask Transformation
对于Mask Transformation
,按我的理解是学习上空间上的Attention
.
其中Mask Transformation
的对于输入K
为encoder
提取到的
T
^
\hat{\mathbf{T}}
T^,而对于Q
则为上一层输出的
S
^
\hat{\mathbf{S}}
S^,输入V
是一个Gaussian-shaped
的mask
,即
M
=
Concat
(
m
1
,
⋯
,
m
n
)
∈
R
n
×
H
×
W
\mathbf{M}=\operatorname{Concat}\left(\mathbf{m}_{1}, \cdots, \mathbf{m}_{n}\right) \in \mathbb{R}^{n \times H \times W}
M=Concat(m1,⋯,mn)∈Rn×H×W(
m
m
m通过Gaussian function
得到,即
m
(
y
)
=
exp
(
−
∥
y
−
c
∥
2
2
σ
2
)
\mathbf{m}(y)=\exp \left(-\frac{\|y-c\|^{2}}{2 \sigma^{2}}\right)
m(y)=exp(−2σ2∥y−c∥2)),同样对
M
M
M进行reshape
后得到
M
′
∈
R
N
T
×
1
\mathbf{M}^{\prime} \in \mathbb{R}^{N_{T} \times 1}
M′∈RNT×1.
最终Mask Transformation
可以表示为:
A T → S = Atten ( ϕ ( S ^ ) , ϕ ( T ^ ) ) ∈ R N S × N T \mathbf{A}_{\mathrm{T} \rightarrow \mathrm{S}}=\operatorname{Atten}(\phi(\hat{\mathbf{S}}), \phi(\hat{\mathbf{T}})) \in \mathbb{R}^{N_{S} \times N_{T}} AT→S=Atten(ϕ(S^),ϕ(T^))∈RNS×NT
S ^ mask = Ins. Norm ( A T → s M ′ ⊗ S ^ ) \hat{\mathbf{S}}_{\text {mask }}=\text { Ins. } \operatorname{Norm}\left(\mathbf{A}_{\mathrm{T} \rightarrow s} \mathbf{M}^{\prime} \otimes \hat{\mathbf{S}}\right) S^mask = Ins. Norm(AT→sM′⊗S^)
where ⊗ \otimes ⊗ is the broadcasting element-wise multiplication
Feature Transformation
对于Feature Transformation
,按我的理解是通过Attention
提升提取到的Search Feature
.
同Mask Transformation
基本一样,不同的是输入的V
是经过与
M
M
M经过element-wise multiplication
的
T
^
\hat{\mathbf{T}}
T^,即
T
^
⊗
M
′
\hat{\mathbf{T}} \otimes \mathbf{M}^{\prime}
T^⊗M′
所以Feature Transformation
可以表示为:
S ^ f e a t = Ins. Norm ( A T → S ( T ^ ⊗ M ′ ) + S ^ ) \hat{\mathbf{S}}_{\mathrm{feat}}=\text { Ins. } \operatorname{Norm}\left(\mathbf{A}_{\mathrm{T} \rightarrow \mathrm{S}}\left(\hat{\mathbf{T}} \otimes \mathbf{M}^{\prime}\right)+\hat{\mathbf{S}}\right) S^feat= Ins. Norm(AT→S(T^⊗M′)+S^)
最终输出的Search Feature
经由下式得到:
S ^ final = Ins. Norm ( S ^ feat + S ^ mask ) \hat{\mathbf{S}}_{\text {final }}=\text { Ins. Norm }\left(\hat{\mathbf{S}}_{\text {feat }}+\hat{\mathbf{S}}_{\text {mask }}\right) S^final = Ins. Norm (S^feat +S^mask )
Tracking with Transformer-enhanced Features
这篇论文将上诉提到的Transfomer
模块应用到了Siamese Pipeline
和DCF pipeline
两种跟踪器上,提出了TrSiam
和TrDimp
.
实验结果
小结
这篇论文将Transfomer
引入了目标跟踪中,并取得了非常好的结果,可能也因为此获得了2021CVPR-oral
.
虽然说这篇论文中引入的Transfomer
取得了很好的结果,但还有以下几点不足:
- 如论文
Appending D
中所说,这个模型仍然无法很好处理occlustion
和out-of-view
. - 如同其他使用
Transfomer
的模型一样,计算attention matrix
需要消耗很大的计算内存,这也导致了这个模型在速度上有所下降.
总之,这篇论文还是很值得研究探讨的!