当前位置:网站首页>Anchor of SSD_ Box calculation
Anchor of SSD_ Box calculation
2022-06-21 12:01:00 【m0_ thirty-seven million one hundred and eighty-eight thousand 】
from :http://www.pianshen.com/article/129360549/
Well written and clear . Anti deletion and anti forgetting , If you have any questions, please contact
seen SSD Of tensorflow The implementation partner must be right anchor_box My calculations are curious , There are also various explanations on the Internet , Today, I will explain the source code and principles .
default_params = SSDParams(
img_shape=(300, 300),
num_classes=21,
no_annotation_label=21,
feat_layers=['block4', 'block7', 'block8', 'block9', 'block10', 'block11'],
feat_shapes=[(38, 38), (19, 19), (10, 10), (5, 5), (3, 3), (1, 1)],
anchor_size_bounds=[0.15, 0.90],
# anchor_size_bounds=[0.20, 0.90],
anchor_sizes=[(21., 45.),
(45., 99.),
(99., 153.),
(153., 207.),
(207., 261.),
(261., 315.)],
# anchor_sizes=[(30., 60.),
# (60., 111.),
# (111., 162.),
# (162., 213.),
# (213., 264.),
# (264., 315.)],
anchor_ratios=[[2, .5],
[2, .5, 3, 1./3],
[2, .5, 3, 1./3],
[2, .5, 3, 1./3],
[2, .5],
[2, .5]],
anchor_steps=[8, 16, 32, 64, 100, 300],
anchor_offset=0.5,
normalizations=[20, -1, -1, -1, -1, -1],
prior_scaling=[0.1, 0.1, 0.2, 0.2]
)
This anchor_box The calculation and anchor_sizes and anchor_ratios of .
Explain first anchor_box The origin of . We assume that the current layer is block4, So our feat_shape Namely (38, 38),
You can understand it as 38*38 individual cell unit , Each unit needs to predict several anchor_box, Different layers , Theoretically speaking, this number is 6 individual , (paper That's what it says on the ). Every box The aspect ratio of is ratios Decisive , paper There are two 1 , as well as 4 Other values . But the author's source code has been mischievously changed .
Look at our aspect ratio , There are no those two 1, Because they are set separately :
anchor_ratios=[[2, .5],
[2, .5, 3, 1./3],
[2, .5, 3, 1./3],
[2, .5, 3, 1./3],
[2, .5],
[2, .5]],
We see the first floor and the last two , There are only two aspect ratios , So there are only three floors 4 Kind of box.
This picture can be said to be fairly accurate , There are mistakes on the Internet , Subject to this . With block4 Layer as an example , Each of him cell The unit has only 4 individual box, Including two squares, one large and one small , And two rectangles .
For small squares , Its side length is min_size, This min_size What is it? ? It is the... In the previous parameters anchor_sizes:
anchor_sizes=[(30., 60.),
(60., 111.),
(111., 162.),
(162., 213.),
(213., 264.),
(264., 315.)]
Each of these acts is a group , Each row corresponds to the corresponding feature layer , The first line corresponds to block4, By analogy , about (30, 60), 30 Namely min_size, 60 Namely max_size.
The side length of the large square is :
Then there are two other rectangles , This is the time anchor_ratios I'll be on my way , There is a formula for the length and width of a rectangle .
This ratio Namely anchor_ratios Inside 2, 5, 3, 1/3 And so on. .
such , On the principle of box The size of is introduced . But don't forget that this size is the size on the original drawing , We need the scale of this dimension relative to the original drawing .
Take a look at this part of the source code :
# Add first anchor boxes with ratio=1.
# sizes Namely (30, 60), img_shape Is the size of the original drawing (300, 300)
h[0] = sizes[0] / img_shape[0]
w[0] = sizes[0] / img_shape[1]
di = 1
if len(sizes) > 1:
h[1] = math.sqrt(sizes[0] * sizes[1]) / img_shape[0]
w[1] = math.sqrt(sizes[0] * sizes[1]) / img_shape[1]
di += 1
# r Namely [2, 5, 3, 1/3]
for i, r in enumerate(ratios):
h[i+di] = sizes[0] / img_shape[0] / math.sqrt(r)
w[i+di] = sizes[0] / img_shape[1] * math.sqrt(r)
Last , Now that we understand anchor_size, This parameter directly determines the current feature layer box Size , You can see that the closer you get to the input layer , box The smaller it is , Closer to the output layer , box The bigger it is , therefore SSD The bottom layer is used to detect small targets , High level is used to detect large targets .
边栏推荐
- Introduction to common source oscilloscope software and RIGOL oscilloscope upper computer software ns-scope
- 100w的数据表比1000w的数据表查询更快吗?
- 架构师培养计划-无限思维——变量
- 2022 safety officer-c certificate title and answer
- HMS Core机器学习服务身份证识别功能,实现信息高效录入
- MySQL-DDL
- MySQL 5.6.49 企业版设置密码复杂度策略
- Broken knowledge
- XML entity injection vulnerability
- STM32cubeMX之 uart问题汇总
猜你喜欢
随机推荐
2022 safety officer-b certificate retraining question bank and simulated examination
动手学数据分析 数据重构
中信建投券商是跟启牛学堂存在什么关系?开券商账户安全吗
广东发产品检测券,消费者也有份
是德示波器軟件,Keysight示波器上比特機軟件NS-Scope
2022年138套数学分析高等代数考研真题参考解答勘误
MySQL-DQL
Matrial3d parameter analysis
重磅,MapStruct 1.5 发布,这次终于支持Map转为Bean了!
MySQL-DML
Quantitative research on heterogeneous communities 4 rate of change with bands
动手学数据分析 数据可视化
ThinkPHP security development specification
Rectangular coverage area
旅行不能治愈心灵
异质化社群量化研究4丨RATE OF CHANGE WITH BANDS
是德示波器软件,Keysight示波器上位机软件NS-Scope
【yolov5s目标检测】opencv加载onnx模型在GPU上进行推理
SSD的anchor_box计算
harmonyos培训一




![SSD [target detection]](/img/f5/1a4a9868cddb24fb08db9fae4db290.png)


