😸SMOKE 主要工作:
- 提出一种端到端的
单目 3D 目标检测
的方法,该方法具有较为简洁的网络结构- 提供一种
多步解缠
(multi-step disentanglement)的方法,从而提高 3D 参数的收敛性以及检测的精度- 在
2019.11.12
提交的时候,SMOKE
在KITTI
数据集上优于所有当时的最先进的单目 3D 目标检测算法
✍️SMOKE
延续了 centernet
的 key-point
做法,认为 2D 检测模块是多余的,只保留了 3D 检测模块。其预测投影下来的 3D 框中心点和其他属性变量,从而得到 3D 框,参考 Disentangling Monocular 3D Object Detection
对预测属性进行了 loss 解耦。这个简单的结构收敛较快且推理耗时较小。
🙀论文 Delving into localization error
中证明了 2D 检测的必要性(帮助 3D 检测学习到共享特征),所以 SMOKE 中去掉 2D 检测模块的做法有待商榷?
网络结构
😸SMOKE 的网络结构非常简洁,主要由 backbone 、关键点分类分支和 3D 框回归分支组成
😼backbone:使用与 centernet
相同的 DLA-34
结构来提取特征,但所有的分层聚合连接(hierarchical aggregation connections)替换为可变形卷积网络(DCN)。此外,由于 GN(group normal)对 batch size 不那么敏感,且对于训练噪声更加鲁棒,因此 SMOKE 将所有的 BN 操作全部换为 GN 操作。所得特征图宽和高为原来的
1
4
\frac{1}{4}
41,通道数为 256
😼3D 目标检测网络:该部分包括关键点分类分支(采用 heatmap)和 3D 框回归分支,这两个分支处理主干特征提取网络 DLA-34 获取到的特征图,并将各自处理后的结果融合后得到 3D 目标检测结果
- 关键点分支:采用与 centernet 中类似的结构来预测关键点,每个物体返回一个关键点。关键点被定义为物体在图像平面上 3D 投影中心,而不是 2D 边界框的中心
✍️如图,红色点为 2D 框中心点,而橙色点为 3D 点投影后的结果。假设
[
x
y
z
]
T
\begin{bmatrix} x & y & z \end{bmatrix}^T
[xyz]T 为物体在相机坐标系下的 3D 中心点,
[
x
c
y
c
]
T
\begin{bmatrix} x_c & y_c \end{bmatrix}^T
[xcyc]T 为 3D 中心点投影到图片上的点(图中橙色点),相机内参矩阵为
K
K
K,则这两个点的投影关系如下:
[
z
⋅
x
c
z
⋅
y
c
z
]
=
K
3
×
3
[
x
y
z
]
\begin{bmatrix} z \cdot x_c \\ z \cdot y_c \\ z \end{bmatrix} = K_{3 \times 3} \begin{bmatrix} x \\ y \\ z \end{bmatrix}
⎣⎡z⋅xcz⋅ycz⎦⎤=K3×3⎣⎡xyz⎦⎤
-
3D 框回归分支:预测相关的 3D 参数,包括 ( x , y , z , l , w , h , θ ) (x, y, z, l, w, h, \theta) (x,y,z,l,w,h,θ) 。其中, ( x , y , z ) (x, y, z) (x,y,z) 为 3D 框的中心点, ( l , w , h ) (l, w, h) (l,w,h) 为 3D 框的长宽高, θ \theta θ 为 3D 框的航角。本文中与
ROI-10D
和disentangling
中类似,用 8 维的变量来表示: [ δ z , δ x c , δ y c , δ w , δ h , δ l , s i n α , c o s α ] \begin{bmatrix} \delta_z, \delta_{x_c}, \delta_{y_c}, \delta_w, \delta_h, \delta_l, sin \alpha, cos \alpha \end{bmatrix} [δz,δxc,δyc,δw,δh,δl,sinα,cosα],都做成的预测偏移量 δ \delta δ 来减小学习的难度-
δ z \delta_z δz:表示相机坐标系下目标的距离
z
的偏移量(offset),根据从数据集中统计出平移平均值 μ z \mu_z μz 和尺度方差 σ z \sigma_z σz,可用 z = μ z + δ z σ z z = \mu_z + \delta_z \sigma_z z=μz+δzσz 得到最终的深度z
-
δ x c \delta_{x_c} δxc 和 δ y c \delta_{y_c} δyc:为
heatmap
中由于下采样引起的量化误差,与 centernet 中一样,从而可得 3D 框中心点预测结果
[ x y z ] = K 3 × 3 − 1 [ z ⋅ ( x c + δ x c ) z ⋅ ( y c + δ y c ) z ] \left[\begin{matrix}x\\y\\z\\\end{matrix}\right]=K_{3\times3}^{-1}\left[\begin{matrix}z\cdot\left(x_c+\delta_{x_c}\right)\\z\cdot\left(y_c+\delta_{y_c}\right)\\z\\\end{matrix}\right] ⎣⎡xyz⎦⎤=K3×3−1⎣⎡z⋅(xc+δxc)z⋅(yc+δyc)z⎦⎤ -
δ h \delta_h δh, δ w \delta_w δw, δ l \delta_l δl:相对于平均值(每类单独统计均值)的长宽高缩放量,通过以下公式可得 3D 框最终的长宽高
[ h w l ] = [ h ‾ ⋅ e δ h w ‾ ⋅ e δ w l ‾ ⋅ e δ l ] \left[\begin{matrix}h\\w\\l\\\end{matrix}\right]\ =\ \left[\begin{matrix}\overline{h}\cdot e^{\delta_h}\\\overline{w}\cdot e^{\delta_w}\\\overline{l}\cdot e^{\delta_l}\\\end{matrix}\right] ⎣⎡hwl⎦⎤ = ⎣⎡h⋅eδhw⋅eδwl⋅eδl⎦⎤
✍️其中, h ‾ \overline{h} h、 w ‾ \overline{w} w 和 l ‾ \overline{l} l 是根据不同类别预先统计数据集中所有类别的平均长宽高 -
s i n α sin \alpha sinα 和 c o s α cos \alpha cosα:将角度编码为
sin
和cos
从而映射为连续值,是角度估计中的常见做法,通过以下公式可得航角 θ \theta θ
α x ′ = a r c t a n ( s i n α c o s α ) α z = { α x ′ − π 2 , i f c o s α ≥ 0 α x ′ + π 2 , i f c o s α < 0 θ = α z + a r c t a n ( x z ) \begin{aligned} &\alpha_x^\prime=arctan\left(\frac{sin\alpha}{cos\alpha}\right) \\ &\alpha_z = \begin{cases} \alpha_x^{'} - \frac{\pi}{2}, & if \ cos \alpha \ge 0 \\ \alpha_x^{'} + \frac{\pi}{2}, & if \ cos \alpha < 0\end{cases} \\ &\theta=\alpha_z+arctan\left(\frac{x}{z}\right) \end{aligned} αx′=arctan(cosαsinα)αz={αx′−2π,αx′+2π,if cosα≥0if cosα<0θ=αz+arctan(zx)
-
🙀最后,通过航角的旋转矩阵
R
θ
R_{\theta}
Rθ、物体的长宽高
[
h
,
w
,
l
]
T
[h, w, l]^T
[h,w,l]T 和中心点位置
[
x
,
y
,
z
]
T
[x, y, z]^T
[x,y,z]T 可构建 3D 边界框的 8 个角点(corners),公式如下:
B
=
R
θ
[
±
h
/
2
±
w
/
2
±
l
/
2
]
+
[
x
y
z
]
B = R_{\theta} \begin{bmatrix} \pm h/2 \\ \pm w/2 \\ \pm l/2 \end{bmatrix} + \begin{bmatrix} x \\ y \\ z \end{bmatrix}
B=Rθ⎣⎡±h/2±w/2±l/2⎦⎤+⎣⎡xyz⎦⎤
损失函数
😼损失函数由关键点分类损失和 3D 框回归损失组成
-
关键点分类损失:与 centernet 类似,在
focal loss
的基础上加权,对中心点附近的位置降低 loss 权重,其公式如下:
L c l s = − 1 N ∑ i , j = 1 h , w ( 1 − y ~ i , j ) β ( 1 − s ~ i , j ) γ l o g ( s ~ i , j ) y ~ i , j = { 0 i f y i , j = 1 y i , j o t h e r w i s e s ~ i , j = { s i , j i f y i , j = 1 1 − s ~ i , j o t h e r w i s e \begin{aligned} & L_{cls} = - \frac{1}{N} \sum_{i, j = 1}^{h, w} (1 - \widetilde{y}_{i, j})^{\beta}(1-\widetilde{s}_{i, j})^{\gamma}log(\widetilde{s}_{i, j}) \\ & \widetilde{y}_{i, j} = \begin{cases} 0 & if \ y_{i, j} = 1 \\ y_{i, j} & otherwise \end{cases} \\ & \widetilde{s}_{i, j} = \begin{cases} s_{i, j} & if \ y_{i, j} = 1 \\ 1 - \widetilde{s}_{i, j} & otherwise \end{cases} \end{aligned} Lcls=−N1i,j=1∑h,w(1−y i,j)β(1−s i,j)γlog(s i,j)y i,j={0yi,jif yi,j=1otherwises i,j={si,j1−s i,jif yi,j=1otherwise
✍️其中, s i , j s_{i, j} si,j 为热图(heatmap)在位置 ( i , j ) (i, j) (i,j) 的预测分数(predicted score), y i , j y_{i, j} yi,j 为真实值(the ground-truth value of each point assigned byGaussian Kernel
), β \beta β 和 γ \gamma γ 为可微调(tunable)的超参数, N N N 是每张图片中关键点的数量 -
3D 框回归损失:将
disentangling loss
进行推广,得到多步形式。对(h, w, l)
,(x, y, z)
和 α \alpha α 分别构建了 3 个 box 的 8 个角点,计算了 3 个解耦 L1 损失,该 L1 损失公式如下:
L r e g = λ N ∥ B ^ − B ∥ 1 L_{reg} = \frac{\lambda}{N} \parallel \widehat{B} - B \parallel_1 Lreg=Nλ∥B −B∥1
✍️其中, λ \lambda λ 为缩放因子(scaling factor), B ^ \widehat{B} B 为预测值, B B B 为真实值-
中心点预测中:使用 3D 框的 gt 中心点 [ x , y , z ] T [x, y, z]^T [x,y,z]T 投影到图像上 [ x c , y c ] T [x_c, y_c]^T [xc,yc]T 来预测中心点 [ x ^ , y ^ , z ^ ] T [\hat{x}, \hat{y}, \hat{z}]^T [x^,y^,z^]T,其他值使用 gt 值代入计算得到 3D 框的 8 个角点坐标
-
观测角预测中:使用 3D 框的 gt 中心点 ( x , y , z ) (x, y, z) (x,y,z) 和 预测的观察角 α ^ z \hat{\alpha}_z α^z 计算 θ \theta θ 角,从而计算得到 3D 框的 8 个角点坐标
-
长宽高预测中:长宽高使用预测值,其他值使用 gt 代入计算得到 3D 框的 8 个角点坐标
✍️其实就是,预测哪种类型的,那一类型的参数就使用预测值,其他使用真实值,从而计算得出 8 个预测角点的坐标
-
😸故最终损失为
L
=
L
c
l
s
+
∑
i
=
1
3
L
r
e
g
(
B
^
i
)
L = L_{cls} + \sum_{i=1}^3 L_{reg}(\widehat{B}_i)
L=Lcls+i=1∑3Lreg(B
i)
SMOKE效果展示
😻论文:https://arxiv.org/pdf/2002.10111.pdf
😻代码:https://github.com/lzccccc/SMOKE