提交 e5759d6c 编写于 作者: J jerrywgz 提交者: ceci3

refine doc, test=develop

上级 2b417437
...@@ -330,7 +330,7 @@ paddle.fluid.layers.polygon_box_transform (ArgSpec(args=['input', 'name'], varar ...@@ -330,7 +330,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.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.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.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.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.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.layers.exponential_decay (ArgSpec(args=['learning_rate', 'decay_steps', 'decay_rate', 'staircase'], varargs=None, keywords=None, defaults=(False,)), ('document', '98a5050bee8522fcea81aa795adaba51'))
......
...@@ -35,8 +35,8 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel { ...@@ -35,8 +35,8 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel {
ctx->HasInput("BoxScore"), ctx->HasInput("BoxScore"),
"Input(BoxScore) of BoxDecoderAndAssignOp should not be null."); "Input(BoxScore) of BoxDecoderAndAssignOp should not be null.");
PADDLE_ENFORCE( PADDLE_ENFORCE(
ctx->HasOutput("OutputBox"), ctx->HasOutput("DecodeBox"),
"Output(OutputBox) of BoxDecoderAndAssignOp should not be null."); "Output(DecodeBox) of BoxDecoderAndAssignOp should not be null.");
PADDLE_ENFORCE( PADDLE_ENFORCE(
ctx->HasOutput("OutputAssignBox"), ctx->HasOutput("OutputAssignBox"),
"Output(OutputAssignBox) of BoxDecoderAndAssignOp should not be null."); "Output(OutputAssignBox) of BoxDecoderAndAssignOp should not be null.");
...@@ -68,9 +68,9 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel { ...@@ -68,9 +68,9 @@ class BoxDecoderAndAssignOp : public framework::OperatorWithKernel {
"of box_score is [N, classnum], The shape of prior_box " "of box_score is [N, classnum], The shape of prior_box "
"is [N, 4]"); "is [N, 4]");
ctx->SetOutputDim("OutputBox", framework::make_ddim({target_box_dims[0], ctx->SetOutputDim("DecodeBox", framework::make_ddim({target_box_dims[0],
target_box_dims[1]})); target_box_dims[1]}));
ctx->ShareLoD("TargetBox", /*->*/ "OutputBox"); ctx->ShareLoD("TargetBox", /*->*/ "DecodeBox");
ctx->SetOutputDim( ctx->SetOutputDim(
"OutputAssignBox", "OutputAssignBox",
framework::make_ddim({prior_box_dims[0], prior_box_dims[1]})); framework::make_ddim({prior_box_dims[0], prior_box_dims[1]}));
...@@ -84,38 +84,32 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -84,38 +84,32 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker {
AddInput( AddInput(
"PriorBox", "PriorBox",
"(Tensor, default Tensor<float>) " "(Tensor, default Tensor<float>) "
"Box list PriorBox is a 2-D Tensor with shape [M, 4] holds M boxes, " "Box list PriorBox is a 2-D Tensor with shape [N, 4] which holds N "
"each box is represented as [xmin, ymin, xmax, ymax], " "boxes and each box is represented as [xmin, ymin, xmax, ymax], "
"[xmin, ymin] is the left top coordinate of the anchor box, " "[xmin, ymin] is the left top coordinate of the anchor box, "
"if the input is image feature map, they are close to the origin " "if the input is image feature map, they are close to the origin "
"of the coordinate system. [xmax, ymax] is the right bottom " "of the coordinate system. [xmax, ymax] is the right bottom "
"coordinate of the anchor box."); "coordinate of the anchor box.");
AddInput("PriorBoxVar", AddInput("PriorBoxVar",
"(Tensor, default Tensor<float>, optional) " "(Tensor, default Tensor<float>, optional) "
"PriorBoxVar is a 2-D Tensor with shape [M, 4] holds M group " "PriorBoxVar is a 2-D Tensor with shape [N, 4] which holds N "
"of variance. PriorBoxVar will set all elements to 1 by " "group of variance. PriorBoxVar will set all elements to 1 by "
"default.") "default.")
.AsDispensable(); .AsDispensable();
AddInput( AddInput("TargetBox",
"TargetBox", "(LoDTensor or Tensor) "
"(LoDTensor or Tensor) This input can be a 2-D LoDTensor with shape " "This input can be a 2-D LoDTensor with shape "
"[N, classnum*4]. [N, classnum*4], each box is represented as " "[N, classnum*4]. It holds N targets for N boxes.");
"[xmin, ymin, xmax, ymax], [xmin, ymin] is the left top coordinate " AddInput("BoxScore",
"of the box if the input is image feature map, they are close to " "(LoDTensor or Tensor) "
"the origin of the coordinate system. [xmax, ymax] is the right " "This input can be a 2-D LoDTensor with shape "
"bottom coordinate of the box. This tensor can contain LoD " "[N, classnum], each box is represented as [classnum] which is "
"information to represent a batch of inputs. One instance of this " "the classification probabilities.");
"batch can contain different numbers of entities.");
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", AddAttr<float>("box_clip",
"(float, default 4.135, np.log(1000. / 16.)) " "(float, default 4.135, np.log(1000. / 16.)) "
"clip box to prevent overflowing") "clip box to prevent overflowing")
.SetDefault(4.135f); .SetDefault(4.135f);
AddOutput("OutputBox", AddOutput("DecodeBox",
"(LoDTensor or Tensor) " "(LoDTensor or Tensor) "
"the output tensor of op with shape [N, classnum * 4] " "the output tensor of op with shape [N, classnum * 4] "
"representing the result of N target boxes decoded with " "representing the result of N target boxes decoded with "
...@@ -130,12 +124,12 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -130,12 +124,12 @@ class BoxDecoderAndAssignOpMaker : public framework::OpProtoAndCheckerMaker {
Bounding Box Coder. 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:
$$ $$
oy = (ph \\times pyv \\times ty + py) - \\frac{th}{2} ox = (pw \\times pxv \\times tx + px) - \\frac{tw}{2}
$$ $$
$$ $$
oy = (ph \\times pyv \\times ty + py) - \\frac{th}{2} oy = (ph \\times pyv \\times ty + py) - \\frac{th}{2}
...@@ -149,15 +143,15 @@ The Decoding schema described below: ...@@ -149,15 +143,15 @@ The Decoding schema described below:
where `tx`, `ty`, `tw`, `th` denote the target box's center coordinates, width where `tx`, `ty`, `tw`, `th` denote the target box's center coordinates, width
and height respectively. Similarly, `px`, `py`, `pw`, `ph` denote the and height respectively. Similarly, `px`, `py`, `pw`, `ph` denote the
priorbox's (anchor) center coordinates, width and height. `pxv`, `pyv`, `pwv`, prior_box's (anchor) center coordinates, width and height. `pxv`, `pyv`, `pwv`,
`phv` denote the variance of the priorbox and `ox`, `oy`, `ow`, `oh` denote the `phv` denote the variance of the prior_box and `ox`, `oy`, `ow`, `oh` denote the
encoded/decoded coordinates, width and height. 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 For each prior_box, use the best non-background class's decoded values to
updata the priorbox locations and get outputassignbox. So, the shape of update the prior_box locations and get output_assign_box. So, the shape of
output_assign_box is the same as priorbox. output_assign_box is the same as PriorBox.
)DOC"); )DOC");
} }
}; };
......
...@@ -101,7 +101,7 @@ class BoxDecoderAndAssignCUDAKernel : public framework::OpKernel<T> { ...@@ -101,7 +101,7 @@ class BoxDecoderAndAssignCUDAKernel : public framework::OpKernel<T> {
auto* prior_box_var = context.Input<framework::Tensor>("PriorBoxVar"); auto* prior_box_var = context.Input<framework::Tensor>("PriorBoxVar");
auto* target_box = context.Input<framework::LoDTensor>("TargetBox"); auto* target_box = context.Input<framework::LoDTensor>("TargetBox");
auto* box_score = context.Input<framework::LoDTensor>("BoxScore"); auto* box_score = context.Input<framework::LoDTensor>("BoxScore");
auto* output_box = context.Output<framework::Tensor>("OutputBox"); auto* output_box = context.Output<framework::Tensor>("DecodeBox");
auto* output_assign_box = auto* output_assign_box =
context.Output<framework::Tensor>("OutputAssignBox"); context.Output<framework::Tensor>("OutputAssignBox");
......
...@@ -27,7 +27,7 @@ class BoxDecoderAndAssignKernel : public framework::OpKernel<T> { ...@@ -27,7 +27,7 @@ class BoxDecoderAndAssignKernel : public framework::OpKernel<T> {
auto* prior_box_var = context.Input<framework::Tensor>("PriorBoxVar"); auto* prior_box_var = context.Input<framework::Tensor>("PriorBoxVar");
auto* target_box = context.Input<framework::LoDTensor>("TargetBox"); auto* target_box = context.Input<framework::LoDTensor>("TargetBox");
auto* box_score = context.Input<framework::LoDTensor>("BoxScore"); auto* box_score = context.Input<framework::LoDTensor>("BoxScore");
auto* output_box = context.Output<framework::Tensor>("OutputBox"); auto* output_box = context.Output<framework::Tensor>("DecodeBox");
auto* output_assign_box = auto* output_assign_box =
context.Output<framework::Tensor>("OutputAssignBox"); context.Output<framework::Tensor>("OutputAssignBox");
int roi_num = target_box->dims()[0]; int roi_num = target_box->dims()[0];
......
...@@ -2238,10 +2238,16 @@ def box_decoder_and_assign(prior_box, ...@@ -2238,10 +2238,16 @@ def box_decoder_and_assign(prior_box,
prior_box_var(${prior_box_var_type}): ${prior_box_var_comment} prior_box_var(${prior_box_var_type}): ${prior_box_var_comment}
target_box(${target_box_type}): ${target_box_comment} target_box(${target_box_type}): ${target_box_comment}
box_score(${box_score_type}): ${box_score_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 name(str|None): The name of this operator
Returns: Returns:
output_box(${output_box_type}): ${output_box_comment} decode_box(Variable), output_assign_box(Variable):
output_assign_box(${output_assign_box_type}): ${output_assign_box_comment}
two variables:
- decode_box(${decode_box_type}): ${decode_box_comment}
- output_assign_box(${output_assign_box_type}): ${output_assign_box_comment}
Examples: Examples:
.. code-block:: python .. code-block:: python
...@@ -2253,13 +2259,13 @@ def box_decoder_and_assign(prior_box, ...@@ -2253,13 +2259,13 @@ def box_decoder_and_assign(prior_box,
name='target_box', shape=[20, 4*81], dtype='float32') name='target_box', shape=[20, 4*81], dtype='float32')
scores = fluid.layers.data( scores = fluid.layers.data(
name='scores', shape=[20, 81], dtype='float32') 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) pb, pbv, loc, scores, 4.135)
""" """
helper = LayerHelper("box_decoder_and_assign", **locals()) 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) dtype=prior_box.dtype)
output_assign_box = helper.create_variable_for_type_inference( output_assign_box = helper.create_variable_for_type_inference(
dtype=prior_box.dtype) dtype=prior_box.dtype)
...@@ -2274,7 +2280,7 @@ def box_decoder_and_assign(prior_box, ...@@ -2274,7 +2280,7 @@ def box_decoder_and_assign(prior_box,
}, },
attrs={"box_clip": box_clip}, attrs={"box_clip": box_clip},
outputs={ outputs={
"OutputBox": output_box, "DecodeBox": decoded_box,
"OutputAssignBox": output_assign_box "OutputAssignBox": output_assign_box
}) })
return output_box, output_assign_box return decoded_box, output_assign_box
...@@ -87,7 +87,7 @@ class TestBoxDecoderAndAssignOpWithLoD(OpTest): ...@@ -87,7 +87,7 @@ class TestBoxDecoderAndAssignOpWithLoD(OpTest):
} }
self.attrs = {'box_clip': box_clip} self.attrs = {'box_clip': box_clip}
self.outputs = { self.outputs = {
'OutputBox': output_box, 'DecodeBox': output_box,
'OutputAssignBox': output_assign_box 'OutputAssignBox': output_assign_box
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册