-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha-fast-rcnn-hard-positive-generation-via-adversary-for-object-detection.html
139 lines (124 loc) · 7.87 KB
/
a-fast-rcnn-hard-positive-generation-via-adversary-for-object-detection.html
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="ch">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Computer Vision Reading Group | A-Fast-RCNN: Hard Positive Generation via Adversary for Object Detection</title>
<link rel="shortcut icon" type="image/png" href="/favicon.png">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<link rel="stylesheet" href="/theme/css/screen.css" type="text/css" />
<link rel="stylesheet" href="/theme/css/pygments.css" type="text/css" />
<link rel="stylesheet" href="/theme/css/print.css" type="text/css" media="print" />
<meta name="generator" content="Pelican" />
<meta name="description" content="" />
<meta name="author" content="hustcv" />
<meta name="keywords" content="detection,adversarial" />
</head>
<body>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="https://github.com/hustcv">GitHub</a></li>
<li><a href="/archives">Archives</a></li>
<li><a href="/tags">Tags</a></li>
<li><a href="/authors">Authors</a></li>
<li><a href="/categories">Categories</a></li>
<li><a href="/notes">Notes</a></li>
</ul>
</nav>
<div class="header_box">
<h1><a href="/">Computer Vision Reading Group</a></h1>
</div>
</header>
<div id="wrapper">
<div id="content"> <h4 class="date">7月 18, 2017</h4>
<article class="post">
<h2 class="title">
<a href="/a-fast-rcnn-hard-positive-generation-via-adversary-for-object-detection.html" rel="bookmark" title="Permanent Link to "A-Fast-RCNN: Hard Positive Generation via Adversary for Object Detection"">A-Fast-RCNN: Hard Positive Generation via Adversary for Object Detection</a>
</h2>
<p><a href="https://arxiv.org/abs/1704.03414">paper</a></p>
<h2>一、论文思想</h2>
<p>训练一个目标检测器,对遮挡和形变鲁棒,目前的主要方法是增加不同场景下的图像数据,但这些数据有时又特别少。作者提出使用对抗生成有遮挡或形变的样本,这些样本对检测器来说识别比较困难,使用这些困难的正样本训练可以增加检测器的鲁棒性。 使用对抗网络生成有遮挡和有形变的两种特征,分别对应网络ASDN和ASTN。使用对抗网络生成有遮挡和有形变的两种特征,分别对应网络ASDN和ASTN。</p>
<h3>1.ASDN</h3>
<ul>
<li>FAST-RCNN中RoI-池化层之后的每个目标proposal卷积特征作为对抗网络的输入,给定一个目标的特征,ASDN尝试生成特征某些部分被dropout的掩码,导致检测器无法识别该物体。</li>
<li><code>ASDN网络初始化</code>:
给定尺寸大小为d×d的特征图X,使用d3×d3的滑动窗,并将滑动窗位置映射到原图,将原图对应位置清零,生成新的特征向量,传入到分类层计算损失,选择具有最大损失的滑动窗,用这个窗口生成二值掩码M(滑动窗位置为1,其余位置为0),用n个目标proposal生成n对对抗网络的训练样本(x1,M1),...,(xn,Mn) ,使用二值交叉熵损失训练ASDN: </li>
</ul>
<p><img alt="cross_extropy" src="images/cross_etropy.jpg"></p>
<ul>
<li>在前向传播过程中,首先使用ASDN在RoI-池化层之后生成特征掩码,然后使用重要性采样法生成二值掩码,使用该掩码将特征对应部位值清零,修改后的特征继续前向传播计算损失。这个过程生成了困难的特征,用于训练检测器。训练过程流程图如下所示:</li>
</ul>
<p><img alt="ASDN" src="images/ASDN.jpg"></p>
<h3>2.ASTN</h3>
<ul>
<li>STN网络包含三部分:定位网络,网格生成器,采样器。定位网络估计出形变的参数(旋转角度、平移距离和缩放因子)。这三个参数作为后两部分的输入,输出是形变后的特征图。论文主要学习定位网络的三个参数。</li>
<li><code>ASTN</code>:
主要关注特征旋转,定位网络包含三层全连接层,前两层是ImageNet预训练的fc6和fc7,训练过程与ASDN类似,ASTN对特征进行形变,使得ASTN将正样本识别成负样本。将特征图划分为4个block,每个block估计四个方向的旋转,增加了任务的复杂度。</li>
<li>两种对抗网络可以相结合,使得检测器更鲁棒,RoI-池化层提取的特征首先传入ASDN丢弃一些激活,之后使用ASTN对特征进行形变,如下图所示:
<img alt="ASTNandASDN" src="images/ASTNandASDN.jpg"></li>
<li>ASDN 与 ASTN 网络组合架构示意。首先创建遮挡蒙版,随后旋转路径以产生用于训练的例子。</li>
</ul>
<h2>二、训练</h2>
<h3>stage1:training a standard Fast-RCNN</h3>
<div class="highlight"><pre><span></span>./experiments/scripts/fast_rcnn_std.sh [GPU_ID] VGG16 pascal_voc
</pre></div>
<h3>stage2:pre-training stage for the adversarial network</h3>
<div class="highlight"><pre><span></span>./experiments/scripts/fast_rcnn_adv_pretrain.sh [GPU_ID] VGG16 pascal_voc
</pre></div>
<h3>stage3:copy the weights of the above two models to initialize the joint model</h3>
<div class="highlight"><pre><span></span>./copy_model.h
</pre></div>
<h3>stage4: joint training of the detector and the adversarial network</h3>
<div class="highlight"><pre><span></span>./experiments/scripts/fast_rcnn_adv.sh [GPU_ID] VGG16 pascal_voc
</pre></div>
<h2>三、代码解析</h2>
<h3>1.sigmod交叉熵</h3>
<ul>
<li>交叉熵化简:<br>
<img alt="交叉熵化简" src="images/f1.jpg"><br>
<img alt="交叉熵化简" src="images/f2.jpg"> </li>
<li>进一步可化简为:<br>
<img alt="交叉熵化简" src="images/f3.jpg"><br>
<img alt="交叉熵化简" src="images/f4.jpg"> </li>
<li>对应本文中的代码是: <strong><em>adversarial-frcnn/lib/roi_data_layer/layer.py</em></strong><br>
<img alt="代码1" src="images/code1.jpg"></li>
<li>代码解析: </li>
</ul>
<h5>1.注意绝对值使用的巧妙之处:</h5>
<p>** lZ = np.log(1+np.exp(-np.abs(f))) * mask
Lz对应化简公式的第二项,其中e的指数项x在两种情况下,均为非正,可以概括为代码中np.exp(-np.abs(f))</p>
<h5>2.注意判断语句使用的巧妙之处:</h5>
<p>*<em> ((f>0)-t)</em>f * mask该项对应化简公式的第一项,对应caffe源码为:<br>
<img alt="代码2" src="images/code2.jpg"></p>
<h2>四、参考链接</h2>
<ul>
<li>caffe网络可视化工具:http://ethereon.github.io/netscope/#/editor</li>
<li>交叉熵公式推导:http://caffecn.cn/?/question/25</li>
<li>交叉熵公式说明:http://blog.csdn.net/u014114990/article/details/47975739</li>
<li>论文代码:https://github.com/xiaolonw/adversarial-frcnn </li>
</ul>
<p><strong>关于作者</strong>
Edited by <a href="https://github.com/orgs/hustcv/people/galaxy-fangfang">fangfang</a> <a href="https://github.com/orgs/hustcv/people/summerZXH">xiuhong</a></p>
<div class="clear"></div>
<div class="info">
<a href="/a-fast-rcnn-hard-positive-generation-via-adversary-for-object-detection.html">posted at 19:54</a>
· <a href="/category/paper.html" rel="tag">Paper</a>
·
<a href="/tag/detection.html" class="tags">detection</a>
<a href="/tag/adversarial.html" class="tags">adversarial</a>
</div>
</article>
<div class="clear"></div>
<footer>
<p>
<a href="https://github.com/jody-frankowski/blue-penguin">Blue Penguin</a> Theme
·
Powered by <a href="http://getpelican.com">Pelican</a>
</footer>
</div>
<div class="clear"></div>
</div>
</body>
</html>