Skip to content

Commit 7a7de93

Browse files
committed
docs(ssd): variance加速
1 parent d95afc2 commit 7a7de93

File tree

5 files changed

+77
-7
lines changed

5 files changed

+77
-7
lines changed

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@
1919
* 先验框
2020
* 匹配策略
2121
* 损失函数
22-
* Hard Negative Mining
22+
* Hard Negative Mining
23+
* variance变量

docs/ssd/data_argumentation.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/ssd/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@
2828
* 输入图像尺寸为$300\times 300$
2929
* 数据集为`PASCAL VOC`
3030

31-
最后再进一步扩充到$500\times 500$的场景
31+
最后再进一步扩充到$500\times 500$的场景
32+
33+
## 相关阅读
34+
35+
* [【SSD算法】史上最全代码解析-核心篇](https://zhuanlan.zhihu.com/p/79854543?from_voters_page=true)

docs/ssd/variance.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
11

2-
# variance变量
2+
# variance变量
3+
4+
## 边界框回归
5+
6+
参考:[[R-CNN]边界框回归](https://blog.zhujian.life/posts/dd3aa53a.html)
7+
8+
已知先验框$P=(P_{x}, P_{y}, P_{w}, P_{h})$和标注框坐标$G=(G_{x}, G_{y}, G_{w}, G_{h})$,计算回归目标$t$
9+
10+
$$
11+
t_{x} = (G_{x} - P_{x}) / P_{w} \\
12+
t_{y} = (G_{y} - P_{y}) / P_{h} \\
13+
t_{w} = \log(G_{w} / P_{w}) \\
14+
t_{h} = \log(G_{h} / P_{h})
15+
$$
16+
17+
## variance使用
18+
19+
不过在`SSD`算法实现中,额外增加了一个`variance`变量
20+
21+
$$
22+
t_{x} = (G_{x} - P_{x}) / P_{w} /center\_variance\\
23+
t_{y} = (G_{y} - P_{y}) / P_{h} /center\_variance\\
24+
t_{w} = \log(G_{w} / P_{w}) /size\_variance\\
25+
t_{h} = \log(G_{h} / P_{h}) /size\_variance
26+
$$
27+
28+
其中
29+
30+
$$
31+
center\_variance = 0.1 \ \
32+
size\_variance=0.2
33+
$$
34+
35+
参考:
36+
37+
[[question] What is the purpose of the variances?](https://github.com/rykov8/ssd_keras/issues/53)
38+
39+
[variance in priorbox layer #155](https://github.com/weiliu89/caffe/issues/155)
40+
41+
[Bounding Box Encoding and Decoding in Object Detection](https://leimao.github.io/blog/Bounding-Box-Encoding-Decoding/)
42+
43+
`variance`的作用在于对回归目标$t$进行了一次归一化操作,从而实现更好的训练精度
44+
45+
$$
46+
{t}' = \frac {t - mean}{variance} = \frac {t - 0}{0.1或者0.2}
47+
$$
48+
49+
`variance`表示的其实是标准方差(`standard variance`
50+
51+
当然最后预测时,同样需要使用`variance`变量
52+
53+
$$
54+
Pred_{x} = {t}'_{x} * center\_variance * P_{w} + P_{x}\\
55+
Pred_{y} = {t}'_{y} * center\_variance * P_{h} + P_{y}\\
56+
Pred_{w} = \exp ({t}'_{w} * size\_variance) * P_{w}\\
57+
Pred_{h} = \exp ({t}'_{h} * size\_variance) * P_{h}
58+
$$
59+
60+
## 具体实现
61+
62+
* `py/ssd/utils/box_utils.py`
63+
64+
```
65+
def convert_locations_to_boxes(locations, priors, center_variance, size_variance):
66+
。。。
67+
def convert_boxes_to_locations(center_form_boxes, center_form_priors, center_variance, size_variance):
68+
。。。
69+
```

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,5 @@ nav:
6969
- 先验框: ssd/prior_boxes.md
7070
- 匹配策略: ssd/matching_strategy.md
7171
- 损失函数: ssd/loss_function.md
72-
- 'Hard Negative Mining': ssd/hard_negative_mining.md
72+
- 'Hard Negative Mining': ssd/hard_negative_mining.md
73+
- variance变量: ssd/variance.md

0 commit comments

Comments
 (0)