原
目標檢測:SSD的數據增強算法
版權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/zbzb1000/article/details/81037852 </div>
<link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-cd6c485e8b.css">
<div id="content_views" class="markdown_views">
<!-- flowchart 箭頭圖標 勿刪 -->
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
<path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path>
</svg>
<h1 id="ssd的數據增強算法"><a name="t0"></a>SSD的數據增強算法</h1>
代碼地址
https://github.com/weiliu89/caffe/tree/ssd
論文地址
https://arxiv.org/abs/1512.02325
數據增強:
SSD數據增強有兩種新方法:(1)expand ,左圖(2)batch_sampler,右圖
expand_param {
prob: 0.5 //expand發生的概率
max_expand_ratio: 4 //expand的擴大倍數
}
- 1
- 2
- 3
- 4
expand是指對圖像進行縮小,圖像的其余區域補0,下圖是expand的方法。個人認為這樣做的目的是在數據處理階段增加多尺度的信息。大object通過expand方法的處理可以變成小尺度的物體訓練。提高ssd對尺度的泛化性。
annotated_data_param {//以下有7個batch_sampler
batch_sampler {
max_sample: 1
max_trials: 1
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.1
}
max_sample: 1
max_trials: 50
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.3
}
max_sample: 1
max_trials: 50
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.5
}
max_sample: 1
max_trials: 50
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.7
}
max_sample: 1
max_trials: 50
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.9
}
max_sample: 1
max_trials: 50
}
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
max_jaccard_overlap: 1
}
max_sample: 1
max_trials: 50
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
batch_sampler是對圖像選取一個滿足限制條件的區域(注意這個區域是隨機抓取的)。限制條件就是抓取的patch和GT(Ground Truth)的IOU的值。
步驟是:先在區間[min_scale,max_sacle]內隨機生成一個值,這個值作為patch的高Height,然后在[min_aspect_ratio,max_aspect_ratio]范圍內生成ratio,從而得到patch的Width。到此為止patch的寬和高隨機得到,然后在圖像中進行一次patch,要求滿足與GT的最小IOU是0.9,也就是IOU>=0.9。如果隨機patch滿足這個條件,那么張圖會被resize到300*300(在SSD300*300中)送進網絡訓練。如下圖。
batch_sampler {
sampler {
min_scale: 0.3
max_scale: 1
min_aspect_ratio: 0.5
max_aspect_ratio: 2
}
sample_constraint {
min_jaccard_overlap: 0.9
}
max_sample: 1
max_trials: 50
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
附
上面的內容是通過jupyter notebook可視化得到的。並沒有詳細看SSD的transform_data的代碼。如果有錯誤的地方,希望大家在評論處批評指正。