Fast RCNN存在的问题
来源
:B站霹雳吧啦Wz
对小目标检测效果很差(加入FPN进行改善)
模型大,检测速度较慢
网络框架:
在六个特征层进行预测不同大小的目标
Default Box的scale以及aspect设定
每层对应的scale以及aspect设定
对于每个Default Box。对于高宽比1,我们还添加了一个Default Box,其比例是,
s
k
′
=
s
k
s
k
+
1
s_{k}^{\prime}=\sqrt{s_{k} s_{k+1}}
sk′=sksk+1
Default Box个数:38x38x4+19x19x6+10x10x6+5x5x6+3x3x4+1x1X4=8732
预测
对于大小为m x n p个channel而言,使用3x3xp大小的卷积核来实现,生成概率分数,以及Default Box的坐标偏移量(边界框回归参数)
对于特征图上的每个位置生成k个Default Box,对每个Default Box计算c个类别分数和4个坐标偏移量,所以需要(c+4)*k个卷积核来实现
对于m x n的feature map会生成(c+4)kmn输出值
在Fast R-CNN中会生成4c个边界框回归参数,在SSD中不会去关注类别
正负样本选取
正样本:与GT匹配最大的IoU;与任何一个GT的IoU大于0.5
负样本:计算剩下负样本的最大的 confidence loss;confidence loss越大,网络预测为目标的概率就越大
负样本:正样本=3:1
计算损失
类别损失 定位损失
L
(
x
,
c
,
l
,
g
)
=
1
N
(
L
conf
(
x
,
c
)
+
α
L
l
o
c
(
x
,
l
,
g
)
L(x, c, l, g)=\frac{1}{N}\left(L_{\text {conf }}(x, c)+\alpha L_{l o c}(x, l, g)\right.
L(x,c,l,g)=N1(Lconf (x,c)+αLloc(x,l,g)
其中N为匹配到的正样本个数,
α
\alpha
α为1
L
conf
(
x
,
c
)
=
−
∑
i
∈
Pos
N
x
i
j
p
log
(
c
^
i
p
)
−
∑
i
∈
N
e
g
log
(
c
^
i
0
)
w
h
e
r
e
c
^
i
p
=
exp
(
c
i
p
)
∑
p
exp
(
c
i
p
)
L_{\text {conf }}(x, c)=-\sum_{i \in \text { Pos }}^{N} x_{i j}^{p} \log \left(\hat{c}_{i}^{p}\right)-\sum_{i \in N e g} \log \left(\hat{c}_{i}^{0}\right) \quad where \quad \hat{c}_{i}^{p}=\frac{\exp \left(c_{i}^{p}\right)}{\sum_{p} \exp \left(c_{i}^{p}\right)}
Lconf (x,c)=−∑i∈ Pos Nxijplog(c^ip)−∑i∈Neglog(c^i0)wherec^ip=∑pexp(cip)exp(cip)
c
^
i
p
\hat{c}_{i}^{p}
c^ip为预测的第
i
i
i个 default box对应
G
T
box
\mathrm{GT} \operatorname{box}
GTbox(类别是
P
)
\mathrm{P})
P) 的概率
x
i
j
p
=
{
0
,
1
}
x_{i j}^{p}=\{0,1\}
xijp={0,1}为第
i
i
i个default box匹配到的第
j
\mathrm{j}
j个 GT box (类别是
P
\mathrm{P}
P)
L
l
o
c
(
x
,
l
,
g
)
=
∑
i
∈
P
o
s
N
∑
m
∈
{
c
x
,
c
y
,
w
,
h
}
x
i
j
k
smooth
L
1
(
l
i
m
−
g
^
j
m
)
L_{l o c}(x, l, g)=\sum_{i \in P o s}^{N} \sum_{m \in\{c x, c y, w, h\}} x_{i j}^{k} \operatorname{smooth}_{\mathrm{L} 1}\left(l_{i}^{m}-\hat{g}_{j}^{m}\right)
Lloc(x,l,g)=∑i∈PosN∑m∈{cx,cy,w,h}xijksmoothL1(lim−g^jm)
g
^
j
c
x
=
(
g
j
c
x
−
d
i
c
x
)
/
d
i
w
\hat{g}_{j}^{c x}=\left(g_{j}^{c x}-d_{i}^{c x}\right) / d_{i}^{w}
g^jcx=(gjcx−dicx)/diw
g
^
j
c
y
=
(
g
j
c
y
−
d
i
c
y
)
/
d
i
h
\hat{g}_{j}^{c y}=\left(g_{j}^{c y}-d_{i}^{c y}\right) / d_{i}^{h}
g^jcy=(gjcy−dicy)/dih
g
^
j
w
=
log
(
g
j
w
d
i
w
)
\hat{g}_{j}^{w}=\log \left(\frac{g_{j}^{w}}{d_{i}^{w}}\right)
g^jw=log(diwgjw)
g
^
j
h
=
log
(
g
j
h
d
i
h
)
\hat{g}_{j}^{h}=\log \left(\frac{g_{j}^{h}}{d_{i}^{h}}\right)
g^jh=log(dihgjh)
smooth
L
1
(
x
)
=
{
0.5
x
2
if
∣
x
∣
<
1
∣
x
∣
−
0.5
otherwise
\operatorname{smooth}_{L_{1}}(x)=\left\{\begin{array}{ll}0.5 x^{2} & \text { if }|x|<1 \\ |x|-0.5 & \text { otherwise }\end{array}\right.
smoothL1(x)={0.5x2∣x∣−0.5 if ∣x∣<1 otherwise
l
i
m
l_{i}^{m}
lim为预测对应第
i
i
i个正样本回归参数
g
^
j
m
\hat{g}_{j}^{m}
g^jm为正样本匹配的第
j
j
j个GT box的回归参数