Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
cb17dd20
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
cb17dd20
编写于
1月 22, 2018
作者:
W
Wang Meng
提交者:
GitHub
1月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7698 from will-am/fix_priorbox
Fix priorbox layer when multiple values given in min_size
上级
32cc11e3
871b0e68
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
36 addition
and
42 deletion
+36
-42
paddle/gserver/layers/PriorBox.cpp
paddle/gserver/layers/PriorBox.cpp
+36
-42
未找到文件。
paddle/gserver/layers/PriorBox.cpp
浏览文件 @
cb17dd20
...
...
@@ -65,14 +65,19 @@ bool PriorBoxLayer::init(const LayerMap& layerMap,
std
::
copy
(
pbConf
.
aspect_ratio
().
begin
(),
pbConf
.
aspect_ratio
().
end
(),
std
::
back_inserter
(
tmp
));
// flip
int
inputRatioLength
=
tmp
.
size
();
for
(
int
index
=
0
;
index
<
inputRatioLength
;
index
++
)
{
aspectRatio_
.
push_back
(
tmp
[
index
]);
aspectRatio_
.
push_back
(
1
/
tmp
[
index
]);
if
(
maxSize_
.
size
()
>
0
)
CHECK_EQ
(
minSize_
.
size
(),
maxSize_
.
size
());
// flip aspect ratios
for
(
int
index
=
0
;
index
<
tmp
.
size
();
index
++
)
{
real
ar
=
tmp
[
index
];
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
continue
;
aspectRatio_
.
push_back
(
ar
);
aspectRatio_
.
push_back
(
1.
/
ar
);
}
numPriors_
=
aspectRatio_
.
size
();
if
(
maxSize_
.
size
()
>
0
)
numPriors_
++
;
numPriors_
=
aspectRatio_
.
size
()
*
minSize_
.
size
()
+
maxSize_
.
size
();
return
true
;
}
...
...
@@ -99,24 +104,26 @@ void PriorBoxLayer::forward(PassType passType) {
for
(
int
w
=
0
;
w
<
layerWidth
;
++
w
)
{
real
centerX
=
(
w
+
0.5
)
*
stepW
;
real
centerY
=
(
h
+
0.5
)
*
stepH
;
real
minSize
=
0
;
for
(
size_t
s
=
0
;
s
<
minSize_
.
size
();
s
++
)
{
// first prior.
minSize
=
minSize_
[
s
];
real
minSize
=
minSize_
[
s
];
real
boxWidth
=
minSize
;
real
boxHeight
=
minSize
;
// xmin, ymin, xmax, ymax.
// priors with different aspect ratios
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
real
ar
=
aspectRatio_
[
r
];
boxWidth
=
minSize
*
sqrt
(
ar
);
boxHeight
=
minSize
/
sqrt
(
ar
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
+
boxHeight
/
2.
)
/
imageHeight
;
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
}
if
(
maxSize_
.
size
()
>
0
)
{
CHECK_EQ
(
minSize_
.
size
(),
maxSize_
.
size
());
// second prior.
for
(
size_t
s
=
0
;
s
<
maxSize_
.
size
();
s
++
)
{
// square prior with size sqrt(minSize * maxSize)
real
maxSize
=
maxSize_
[
s
];
boxWidth
=
boxHeight
=
sqrt
(
minSize
*
maxSize
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
...
...
@@ -128,21 +135,8 @@ void PriorBoxLayer::forward(PassType passType) {
}
}
}
// rest of priors.
for
(
size_t
r
=
0
;
r
<
aspectRatio_
.
size
();
r
++
)
{
real
ar
=
aspectRatio_
[
r
];
if
(
fabs
(
ar
-
1.
)
<
1e-6
)
continue
;
real
boxWidth
=
minSize
*
sqrt
(
ar
);
real
boxHeight
=
minSize
/
sqrt
(
ar
);
tmpPtr
[
idx
++
]
=
(
centerX
-
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
-
boxHeight
/
2.
)
/
imageHeight
;
tmpPtr
[
idx
++
]
=
(
centerX
+
boxWidth
/
2.
)
/
imageWidth
;
tmpPtr
[
idx
++
]
=
(
centerY
+
boxHeight
/
2.
)
/
imageHeight
;
// set the variance.
for
(
int
t
=
0
;
t
<
4
;
t
++
)
tmpPtr
[
idx
++
]
=
variance_
[
t
];
}
}
}
// clip the prior's coordidate such that it is within [0, 1]
for
(
int
d
=
0
;
d
<
dim
*
2
;
++
d
)
if
((
d
%
8
)
<
4
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录