Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
c3e89f30
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c3e89f30
编写于
1月 31, 2018
作者:
G
gaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update accoding to the code review
上级
02d2b7b6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
33 deletion
+41
-33
paddle/operators/box_coder_op.cu
paddle/operators/box_coder_op.cu
+0
-2
python/paddle/v2/fluid/tests/test_box_coder_op.py
python/paddle/v2/fluid/tests/test_box_coder_op.py
+41
-31
未找到文件。
paddle/operators/box_coder_op.cu
浏览文件 @
c3e89f30
...
...
@@ -15,8 +15,6 @@ limitations under the License. */
namespace
paddle
{
namespace
operators
{
using
platform
::
PADDLE_CUDA_NUM_THREADS
;
template
<
typename
T
>
__global__
void
EncodeCenterSizeKernel
(
const
T
*
prior_box_data
,
const
T
*
prior_box_var_data
,
...
...
python/paddle/v2/fluid/tests/test_box_coder_op.py
浏览文件 @
c3e89f30
...
...
@@ -20,41 +20,51 @@ from op_test import OpTest
def
box_coder
(
target_box
,
prior_box
,
prior_box_var
,
output_box
,
code_type
):
prior_box_x
=
(
prior_box
[:,
2
]
+
prior_box
[:,
0
])
/
2
prior_box_y
=
(
prior_box
[:,
3
]
+
prior_box
[:,
1
])
/
2
prior_box_width
=
(
prior_box
[:,
2
]
-
prior_box
[:,
0
])
prior_box_height
=
(
prior_box
[:,
3
]
-
prior_box
[:,
1
])
prior_box_x
=
(
(
prior_box
[:,
2
]
+
prior_box
[:,
0
])
/
2
).
reshape
(
1
,
prior_box
.
shape
[
0
])
prior_box_y
=
(
(
prior_box
[:,
3
]
+
prior_box
[:,
1
])
/
2
).
reshape
(
1
,
prior_box
.
shape
[
0
])
prior_box_width
=
(
(
prior_box
[:,
2
]
-
prior_box
[:,
0
])).
reshape
(
1
,
prior_box
.
shape
[
0
])
prior_box_height
=
(
(
prior_box
[:,
3
]
-
prior_box
[:,
1
])).
reshape
(
1
,
prior_box
.
shape
[
0
])
prior_box_var
=
prior_box_var
.
reshape
(
1
,
prior_box_var
.
shape
[
0
],
prior_box_var
.
shape
[
1
])
if
(
code_type
==
"EncodeCenterSize"
):
target_box_x
=
(
target_box
[:,
2
]
+
target_box
[:,
0
])
/
2
target_box_y
=
(
target_box
[:,
3
]
+
target_box
[:,
1
])
/
2
target_box_width
=
(
target_box
[:,
2
]
-
target_box
[:,
0
])
target_box_height
=
(
target_box
[:,
3
]
-
target_box
[:,
1
])
for
i
in
range
(
target_box
.
shape
[
0
]):
output_box
[
i
,:,
0
]
=
(
target_box_x
[
i
]
-
prior_box_x
)
/
prior_box_width
/
\
prior_box_var
[:,
0
]
output_box
[
i
,:,
1
]
=
(
target_box_y
[
i
]
-
prior_box_y
)
/
prior_box_height
/
\
prior_box_var
[:,
1
]
output_box
[
i
,:,
2
]
=
np
.
log
(
np
.
fabs
(
target_box_width
[
i
]
/
prior_box_width
))
/
\
prior_box_var
[:,
2
]
output_box
[
i
,:,
3
]
=
np
.
log
(
np
.
fabs
(
target_box_height
[
i
]
/
prior_box_height
))
/
\
prior_box_var
[:,
3
]
target_box_x
=
((
target_box
[:,
2
]
+
target_box
[:,
0
])
/
2
).
reshape
(
target_box
.
shape
[
0
],
1
)
target_box_y
=
((
target_box
[:,
3
]
+
target_box
[:,
1
])
/
2
).
reshape
(
target_box
.
shape
[
0
],
1
)
target_box_width
=
((
target_box
[:,
2
]
-
target_box
[:,
0
])).
reshape
(
target_box
.
shape
[
0
],
1
)
target_box_height
=
((
target_box
[:,
3
]
-
target_box
[:,
1
])).
reshape
(
target_box
.
shape
[
0
],
1
)
output_box
[:,:,
0
]
=
(
target_box_x
-
prior_box_x
)
/
prior_box_width
/
\
prior_box_var
[:,:,
0
]
output_box
[:,:,
1
]
=
(
target_box_y
-
prior_box_y
)
/
prior_box_height
/
\
prior_box_var
[:,:,
1
]
output_box
[:,:,
2
]
=
np
.
log
(
np
.
fabs
(
target_box_width
/
prior_box_width
))
/
\
prior_box_var
[:,:,
2
]
output_box
[:,:,
3
]
=
np
.
log
(
np
.
fabs
(
target_box_height
/
prior_box_height
))
/
\
prior_box_var
[:,:,
3
]
elif
(
code_type
==
"DecodeCenterSize"
):
for
i
in
range
(
target_box
.
shape
[
0
]):
target_box_x
=
prior_box_var
[:,
0
]
*
target_box
[
i
][
0
]
*
\
prior_box_width
[:]
+
prior_box_x
[:]
target_box_y
=
prior_box_var
[:,
1
]
*
target_box
[
i
][
1
]
*
\
prior_box_height
[:]
+
prior_box_y
[:]
target_box_width
=
np
.
exp
(
prior_box_var
[:,
2
]
*
target_box
[
i
][
2
])
*
\
prior_box_width
[:]
target_box_height
=
np
.
exp
(
prior_box_var
[:,
3
]
*
target_box
[
i
][
3
])
*
\
prior_box_height
[:]
output_box
[
i
,
:,
0
]
=
target_box_x
-
target_box_width
/
2
output_box
[
i
,
:,
1
]
=
target_box_y
-
target_box_height
/
2
output_box
[
i
,
:,
2
]
=
target_box_x
+
target_box_width
/
2
output_box
[
i
,
:,
3
]
=
target_box_y
+
target_box_height
/
2
target_box
=
target_box
.
reshape
(
target_box
.
shape
[
0
],
1
,
target_box
.
shape
[
1
])
target_box_x
=
prior_box_var
[:,:,
0
]
*
target_box
[:,:,
0
]
*
\
prior_box_width
+
prior_box_x
target_box_y
=
prior_box_var
[:,:,
1
]
*
target_box
[:,:,
1
]
*
\
prior_box_height
+
prior_box_y
target_box_width
=
np
.
exp
(
prior_box_var
[:,:,
2
]
*
target_box
[:,:,
2
])
*
\
prior_box_width
target_box_height
=
np
.
exp
(
prior_box_var
[:,:,
3
]
*
target_box
[:,:,
3
])
*
\
prior_box_height
output_box
[:,
:,
0
]
=
target_box_x
-
target_box_width
/
2
output_box
[:,
:,
1
]
=
target_box_y
-
target_box_height
/
2
output_box
[:,
:,
2
]
=
target_box_x
+
target_box_width
/
2
output_box
[:,
:,
3
]
=
target_box_y
+
target_box_height
/
2
def
batch_box_coder
(
prior_box
,
prior_box_var
,
target_box
,
lod
,
code_type
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录