針對(duì)不同的物體大小(Object Scales),傳統(tǒng)的方法將圖像轉(zhuǎn)化成不同的大小,分別處理然后把結(jié)果綜合。
這里ssd從不同的卷積層利用featuremap,可以達(dá)到同樣的效果
生成預(yù)測(cè)的方法
如下圖所示:

ssd-feature map.png
最左側(cè)是選取的神經(jīng)網(wǎng)絡(luò)中的一個(gè)“圖像”層
每個(gè)層做3個(gè)處理:
(1)生成loc預(yù)測(cè),厚度4 x box
(2)生成類別預(yù)測(cè),厚度21(類別) x box
(3)生成priorbox,這里面有個(gè)box大小范圍、寬長(zhǎng)比(2 3)等等
prior_box_param {
min_size: 276.0
max_size: 330.0
aspect_ratio: 2
aspect_ratio: 3
flip: true
clip: true
variance: 0.1
variance: 0.1
variance: 0.2
variance: 0.2
}
ssd實(shí)例說(shuō)明
(1)基本網(wǎng)絡(luò)
| Layer name | "圖像"規(guī)格 |
|---|---|
| input | 3x300x300 |
| conv1_1 | 64x300x300 |
| conv1_2 | 64x300x300 |
| pool_1 | 64x150x150 |
| conv2_1 | 128x150x150 |
| conv2_2 | 128x150x150 |
| pool_2 | 128x75x75 |
| conv3_1 | 256x75x75 |
| conv3_2 | 256x75x75 |
| conv3_3 | 256x75x75 |
| pool_3 | 256x38x38 |
| conv4_1 | 512x38x38 |
| conv4_2 | 512x38x38 |
| conv4_3 | 512x38x38 |
| pool_4 | 5121919 |
| conv5_1 | 512x19x19 |
| conv5_2 | 512x19x19 |
| conv5_3 | 512x19x19 |
| ----------- | VGG昏割線 |
| fc6(convolution kernel dilation) | 1024x19x19 |
| fc7 | 1024x19x19 |
| conv6_1 | 256x19x19 |
| conv6_2 | 512x10x10 |
| conv7_1 | 128x10x10 |
| conv7_2(10-3+1*2)/2+1 | 256x5x5 |
| conv8_1 | 128x5x5 |
| conv8_2 | 256x3x3 |
| pool6 | 25611 |
選取提取特征的層
| Layer name | "圖像"規(guī)格 | 特征生成 | 特征說(shuō)明 |
|---|---|---|---|
| conv4_3 | 512x38x38 | mbox-loc conv | 38x38x12(=3x4) |
| mbox-conf conv | 38x38x63(=3x21) | ||
| prior-box | box min:30 | ||
| fc7 | 1024x19x19 | mbox-loc conv | 19x19x24(=6x4) |
| mbox-conf conv | 19x19x126(=6x21) | ||
| prior-box | box min:60 max:114 | ||
| conv6_2 | 512x10x10 | mbox-loc conv | 10x10x24(=6x4) |
| mbox-conf conv | 10x10x126(=6x21) | ||
| prior-box | box min:114 max:168 | ||
| conv7_2 | 256x5x5 | mbox-loc conv | 5x5x24(=6x4) |
| mbox-conf conv | 5x5x126(=6x21) | ||
| prior-box | box min:168 max:222 | ||
| conv8_2 | 256x3x3 | mbox-loc conv | 3x3x24(=6x4) |
| mbox-conf conv | 3x3x126(=6x21) | ||
| prior-box | box min:222 max:276 | ||
| pool_6 | 256x1x1 | mbox-loc conv | 1x1x24(=6x4) |
| mbox-conf conv | 1x1x126(=6x21) | ||
| prior-box | box min:276 max:330 |

loc-conf.png
所以對(duì)一張圖一共提供:
38x38x3+(19x19+10x10+5x5+3x3+1x1)x6=7308個(gè)detection
每個(gè)detection包括4個(gè)值表示位置和21個(gè)值表示每個(gè)類的概率
為了實(shí)現(xiàn)ssd,原生的caffe是不行的
要定義新層:
Normalize
Permute
MultiBoxLoss等
一篇定義新層的方法如下所示:
http://blog.csdn.net/kuaitoukid/article/details/41865803
設(shè)計(jì)feature map##
已知一個(gè)神經(jīng)網(wǎng)絡(luò),選特定層,再后面加:
layer {
name: "conv6_2_mbox_loc"
type: "Convolution"
bottom: "conv6_2"
top: "conv6_2_mbox_loc"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 24/////////////////////////////////////////////////////////////////////n*4
pad: 1/////////////////////////////////////////////////////////////////////這樣feature size由所選層長(zhǎng)寬決定
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "conv6_2_mbox_loc_perm"
type: "Permute"
bottom: "conv6_2_mbox_loc"
top: "conv6_2_mbox_loc_perm"
permute_param {
order: 0
order: 2
order: 3
order: 1
}
}
layer {
name: "conv6_2_mbox_loc_flat"
type: "Flatten"
bottom: "conv6_2_mbox_loc_perm"
top: "conv6_2_mbox_loc_flat"
flatten_param {
axis: 1
}
}
layer {
name: "conv6_2_mbox_conf"
type: "Convolution"
bottom: "conv6_2"
top: "conv6_2_mbox_conf"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 126/////////////////////////////////////////////////////////////////////n*種類
pad: 1/////////////////////////////////////////////////////////////////////這樣feature size由所選層長(zhǎng)寬決定
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "conv6_2_mbox_conf_perm"
type: "Permute"
bottom: "conv6_2_mbox_conf"
top: "conv6_2_mbox_conf_perm"
permute_param {
order: 0
order: 2
order: 3
order: 1
}
}
layer {
name: "conv6_2_mbox_conf_flat"
type: "Flatten"
bottom: "conv6_2_mbox_conf_perm"
top: "conv6_2_mbox_conf_flat"
flatten_param {
axis: 1
}
}
layer {
name: "conv6_2_mbox_priorbox"
type: "PriorBox"
bottom: "conv6_2"
bottom: "data"
top: "conv6_2_mbox_priorbox"
prior_box_param {
min_size: 114.0 /////////////////////////////////////////////////////////////////////適配圖像
max_size: 168.0
aspect_ratio: 2
aspect_ratio: 3
flip: true
clip: true
variance: 0.1
variance: 0.1
variance: 0.2
variance: 0.2
}
}