Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
072eca34
P
Paddle
项目概览
PaddlePaddle
/
Paddle
11 个月 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
072eca34
编写于
3月 05, 2019
作者:
J
jerrywgz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine doc, test=develop
上级
b4f51802
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
44 addition
and
44 deletion
+44
-44
paddle/fluid/API.spec
paddle/fluid/API.spec
+1
-1
paddle/fluid/operators/detection/box_decoder_and_assign_op.cc
...le/fluid/operators/detection/box_decoder_and_assign_op.cc
+28
-34
paddle/fluid/operators/detection/box_decoder_and_assign_op.cu
...le/fluid/operators/detection/box_decoder_and_assign_op.cu
+1
-1
paddle/fluid/operators/detection/box_decoder_and_assign_op.h
paddle/fluid/operators/detection/box_decoder_and_assign_op.h
+1
-1
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+12
-6
python/paddle/fluid/tests/unittests/test_box_decoder_and_assign_op.py
...e/fluid/tests/unittests/test_box_decoder_and_assign_op.py
+1
-1
未找到文件。
paddle/fluid/API.spec
浏览文件 @
072eca34
...
...
@@ -328,7 +328,7 @@ paddle.fluid.layers.polygon_box_transform (ArgSpec(args=['input', 'name'], varar
paddle.fluid.layers.yolov3_loss (ArgSpec(args=['x', 'gtbox', 'gtlabel', 'anchors', 'anchor_mask', 'class_num', 'ignore_thresh', 'downsample_ratio', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '991e934c3e09abf0edec7c9c978b4691'))
paddle.fluid.layers.box_clip (ArgSpec(args=['input', 'im_info', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '397e9e02b451d99c56e20f268fa03f2e'))
paddle.fluid.layers.multiclass_nms (ArgSpec(args=['bboxes', 'scores', 'score_threshold', 'nms_top_k', 'keep_top_k', 'nms_threshold', 'normalized', 'nms_eta', 'background_label', 'name'], varargs=None, keywords=None, defaults=(0.3, True, 1.0, 0, None)), ('document', 'ca7d1107b6c5d2d6d8221039a220fde0'))
paddle.fluid.layers.box_decoder_and_assign (ArgSpec(args=['prior_box', 'prior_box_var', 'target_box', 'box_score', 'box_clip', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '
fb470052db88526a94a7e5de9d9b3a4c
'))
paddle.fluid.layers.box_decoder_and_assign (ArgSpec(args=['prior_box', 'prior_box_var', 'target_box', 'box_score', 'box_clip', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '
005a5ae47d6c8fff721931d69d072b9f
'))
paddle.fluid.layers.accuracy (ArgSpec(args=['input', 'label', 'k', 'correct', 'total'], varargs=None, keywords=None, defaults=(1, None, None)), ('document', '9808534c12c5e739a10f73ebb0b4eafd'))
paddle.fluid.layers.auc (ArgSpec(args=['input', 'label', 'curve', 'num_thresholds', 'topk', 'slide_steps'], varargs=None, keywords=None, defaults=('ROC', 4095, 1, 1)), ('document', 'e0e95334fce92d16c2d9db6e7caffc47'))
paddle.fluid.layers.exponential_decay (ArgSpec(args=['learning_rate', 'decay_steps', 'decay_rate', 'staircase'], varargs=None, keywords=None, defaults=(False,)), ('document', '98a5050bee8522fcea81aa795adaba51'))
...
...
paddle/fluid/operators/detection/box_decoder_and_assign_op.cc
浏览文件 @
072eca34
...
...
@@ -35,8 +35,8 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel {
ctx
->
HasInput
(
"BoxScore"
),
"Input(BoxScore) of BoxDecoderAndAssignOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"
Output
Box"
),
"Output(
Output
Box) of BoxDecoderAndAssignOp should not be null."
);
ctx
->
HasOutput
(
"
Decode
Box"
),
"Output(
Decode
Box) of BoxDecoderAndAssignOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"OutputAssignBox"
),
"Output(OutputAssignBox) of BoxDecoderAndAssignOp should not be null."
);
...
...
@@ -68,9 +68,9 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel {
"of box_score is [N, classnum], The shape of prior_box "
"is [N, 4]"
);
ctx
->
SetOutputDim
(
"
Output
Box"
,
framework
::
make_ddim
({
target_box_dims
[
0
],
ctx
->
SetOutputDim
(
"
Decode
Box"
,
framework
::
make_ddim
({
target_box_dims
[
0
],
target_box_dims
[
1
]}));
ctx
->
ShareLoD
(
"TargetBox"
,
/*->*/
"
Output
Box"
);
ctx
->
ShareLoD
(
"TargetBox"
,
/*->*/
"
Decode
Box"
);
ctx
->
SetOutputDim
(
"OutputAssignBox"
,
framework
::
make_ddim
({
prior_box_dims
[
0
],
prior_box_dims
[
1
]}));
...
...
@@ -84,38 +84,32 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker {
AddInput
(
"PriorBox"
,
"(Tensor, default Tensor<float>) "
"Box list PriorBox is a 2-D Tensor with shape [
M, 4] holds M boxes,
"
"each box is represented as [xmin, ymin, xmax, ymax], "
"Box list PriorBox is a 2-D Tensor with shape [
N, 4] which holds N
"
"
boxes and
each box is represented as [xmin, ymin, xmax, ymax], "
"[xmin, ymin] is the left top coordinate of the anchor box, "
"if the input is image feature map, they are close to the origin "
"of the coordinate system. [xmax, ymax] is the right bottom "
"coordinate of the anchor box."
);
AddInput
(
"PriorBoxVar"
,
"(Tensor, default Tensor<float>, optional) "
"PriorBoxVar is a 2-D Tensor with shape [
M, 4] holds M group
"
"of variance. PriorBoxVar will set all elements to 1 by "
"PriorBoxVar is a 2-D Tensor with shape [
N, 4] which holds N
"
"
group
of variance. PriorBoxVar will set all elements to 1 by "
"default."
)
.
AsDispensable
();
AddInput
(
"TargetBox"
,
"(LoDTensor or Tensor) This input can be a 2-D LoDTensor with shape "
"[N, classnum*4]. [N, classnum*4], each box is represented as "
"[xmin, ymin, xmax, ymax], [xmin, ymin] is the left top coordinate "
"of the box if the input is image feature map, they are close to "
"the origin of the coordinate system. [xmax, ymax] is the right "
"bottom coordinate of the box. This tensor can contain LoD "
"information to represent a batch of inputs. One instance of this "
"batch can contain different numbers of entities."
);
AddInput
(
"BoxScore"
,
"(LoDTensor or Tensor) This input can be a 2-D LoDTensor with shape "
AddInput
(
"TargetBox"
,
"(LoDTensor or Tensor) "
"This input can be a 2-D LoDTensor with shape "
"[N, classnum*4]. It holds N targets for N boxes."
);
AddInput
(
"BoxScore"
,
"(LoDTensor or Tensor) "
"This input can be a 2-D LoDTensor with shape "
"[N, classnum], each box is represented as [classnum] which is "
"the classification probabilities."
);
AddAttr
<
float
>
(
"box_clip"
,
"(float, default 4.135, np.log(1000. / 16.)) "
"clip box to prevent overflowing"
)
.
SetDefault
(
4.135
f
);
AddOutput
(
"
Output
Box"
,
AddOutput
(
"
Decode
Box"
,
"(LoDTensor or Tensor) "
"the output tensor of op with shape [N, classnum * 4] "
"representing the result of N target boxes decoded with "
...
...
@@ -130,12 +124,12 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker {
Bounding Box Coder.
Decode the target bounding box with the priorbox information.
Decode the target bounding box with the prior
_
box information.
The Decoding schema described below:
The Decoding schema
is
described below:
$$
o
y = (ph \\times pyv \\times ty + py) - \\frac{th
}{2}
o
x = (pw \\times pxv \\times tx + px) - \\frac{tw
}{2}
$$
$$
oy = (ph \\times pyv \\times ty + py) - \\frac{th}{2}
...
...
@@ -149,15 +143,15 @@ The Decoding schema described below:
where `tx`, `ty`, `tw`, `th` denote the target box's center coordinates, width
and height respectively. Similarly, `px`, `py`, `pw`, `ph` denote the
priorbox's (anchor) center coordinates, width and height. `pxv`, `pyv`, `pwv`,
`phv` denote the variance of the priorbox and `ox`, `oy`, `ow`, `oh` denote the
encoded/decoded coordinates, width and height.
prior
_
box's (anchor) center coordinates, width and height. `pxv`, `pyv`, `pwv`,
`phv` denote the variance of the prior
_
box and `ox`, `oy`, `ow`, `oh` denote the
decoded coordinates, width and height in decode_box.
After box decode, the Assigning schema
described below:
decode_box is obtained after box decode, then assigning schema is
described below:
For each priorbox, use the best non-background class's decoded values to
updat
a the priorbox locations and get outputassign
box. So, the shape of
output_assign_box is the same as
priorb
ox.
For each prior
_
box, use the best non-background class's decoded values to
updat
e the prior_box locations and get output_assign_
box. So, the shape of
output_assign_box is the same as
PriorB
ox.
)DOC"
);
}
};
...
...
paddle/fluid/operators/detection/box_decoder_and_assign_op.cu
浏览文件 @
072eca34
...
...
@@ -101,7 +101,7 @@ class BoxDecoderAndAssignCUDAKernel : public framework::OpKernel<T> {
auto
*
prior_box_var
=
context
.
Input
<
framework
::
Tensor
>
(
"PriorBoxVar"
);
auto
*
target_box
=
context
.
Input
<
framework
::
LoDTensor
>
(
"TargetBox"
);
auto
*
box_score
=
context
.
Input
<
framework
::
LoDTensor
>
(
"BoxScore"
);
auto
*
output_box
=
context
.
Output
<
framework
::
Tensor
>
(
"
Output
Box"
);
auto
*
output_box
=
context
.
Output
<
framework
::
Tensor
>
(
"
Decode
Box"
);
auto
*
output_assign_box
=
context
.
Output
<
framework
::
Tensor
>
(
"OutputAssignBox"
);
...
...
paddle/fluid/operators/detection/box_decoder_and_assign_op.h
浏览文件 @
072eca34
...
...
@@ -27,7 +27,7 @@ class BoxDecoderAndAssignKernel : public framework::OpKernel<T> {
auto
*
prior_box_var
=
context
.
Input
<
framework
::
Tensor
>
(
"PriorBoxVar"
);
auto
*
target_box
=
context
.
Input
<
framework
::
LoDTensor
>
(
"TargetBox"
);
auto
*
box_score
=
context
.
Input
<
framework
::
LoDTensor
>
(
"BoxScore"
);
auto
*
output_box
=
context
.
Output
<
framework
::
Tensor
>
(
"
Output
Box"
);
auto
*
output_box
=
context
.
Output
<
framework
::
Tensor
>
(
"
Decode
Box"
);
auto
*
output_assign_box
=
context
.
Output
<
framework
::
Tensor
>
(
"OutputAssignBox"
);
int
roi_num
=
target_box
->
dims
()[
0
];
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
072eca34
...
...
@@ -2238,10 +2238,16 @@ def box_decoder_and_assign(prior_box,
prior_box_var(${prior_box_var_type}): ${prior_box_var_comment}
target_box(${target_box_type}): ${target_box_comment}
box_score(${box_score_type}): ${box_score_comment}
box_clip(${box_clip_type}): ${box_clip_comment}
name(str|None): The name of this operator
Returns:
output_box(${output_box_type}): ${output_box_comment}
output_assign_box(${output_assign_box_type}): ${output_assign_box_comment}
decode_box(Variable), output_assign_box(Variable):
two variables:
- decode_box(${decode_box_type}): ${decode_box_comment}
- output_assign_box(${output_assign_box_type}): ${output_assign_box_comment}
Examples:
.. code-block:: python
...
...
@@ -2253,13 +2259,13 @@ def box_decoder_and_assign(prior_box,
name='target_box', shape=[20, 4*81], dtype='float32')
scores = fluid.layers.data(
name='scores', shape=[20, 81], dtype='float32')
output_box,
assign_box = fluid.layers.box_decoder_and_assign(
decoded_box, output_
assign_box = fluid.layers.box_decoder_and_assign(
pb, pbv, loc, scores, 4.135)
"""
helper
=
LayerHelper
(
"box_decoder_and_assign"
,
**
locals
())
output
_box
=
helper
.
create_variable_for_type_inference
(
decoded
_box
=
helper
.
create_variable_for_type_inference
(
dtype
=
prior_box
.
dtype
)
output_assign_box
=
helper
.
create_variable_for_type_inference
(
dtype
=
prior_box
.
dtype
)
...
...
@@ -2274,7 +2280,7 @@ def box_decoder_and_assign(prior_box,
},
attrs
=
{
"box_clip"
:
box_clip
},
outputs
=
{
"
OutputBox"
:
output
_box
,
"
DecodeBox"
:
decoded
_box
,
"OutputAssignBox"
:
output_assign_box
})
return
output
_box
,
output_assign_box
return
decoded
_box
,
output_assign_box
python/paddle/fluid/tests/unittests/test_box_decoder_and_assign_op.py
浏览文件 @
072eca34
...
...
@@ -87,7 +87,7 @@ class TestBoxDecoderAndAssignOpWithLoD(OpTest):
}
self
.
attrs
=
{
'box_clip'
:
box_clip
}
self
.
outputs
=
{
'
Output
Box'
:
output_box
,
'
Decode
Box'
:
output_box
,
'OutputAssignBox'
:
output_assign_box
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录