Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
abb5a9c7
P
Paddle
项目概览
机器未来
/
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看板
提交
abb5a9c7
编写于
3月 09, 2019
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix doc statement. test=develop
上级
b399ee2a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
34 deletion
+38
-34
paddle/fluid/operators/detection/yolo_box_op.cc
paddle/fluid/operators/detection/yolo_box_op.cc
+33
-32
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+5
-2
未找到文件。
paddle/fluid/operators/detection/yolo_box_op.cc
浏览文件 @
abb5a9c7
...
@@ -75,25 +75,25 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -75,25 +75,25 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
void
Make
()
override
{
void
Make
()
override
{
AddInput
(
"X"
,
AddInput
(
"X"
,
"The input tensor of YoloBox operator, "
"The input tensor of YoloBox operator, "
"This is a 4-D tensor with shape of [N, C, H, W]."
"This is a 4-D tensor with shape of [N, C, H, W].
"
"H and W should be same, and the second dimension(C) stores"
"H and W should be same, and the second dimension(C) stores
"
"box locations, confidence score and classification one-hot"
"box locations, confidence score and classification one-hot
"
"keys of each anchor box. Generally, X should be the output"
"keys of each anchor box. Generally, X should be the output
"
"of YOLOv3 network."
);
"of YOLOv3 network."
);
AddInput
(
"ImgSize"
,
AddInput
(
"ImgSize"
,
"The image size tensor of YoloBox operator, "
"The image size tensor of YoloBox operator, "
"This is a 2-D tensor with shape of [N, 2]. This tensor holds"
"This is a 2-D tensor with shape of [N, 2]. This tensor holds
"
"height and width of each input image using for resize output"
"height and width of each input image using for resize output
"
"box in input image scale."
);
"box in input image scale."
);
AddOutput
(
"Boxes"
,
AddOutput
(
"Boxes"
,
"The output tensor of detection boxes of YoloBox operator, "
"The output tensor of detection boxes of YoloBox operator, "
"This is a 3-D tensor with shape of [N, M, 4], N is the"
"This is a 3-D tensor with shape of [N, M, 4], N is the
"
"batch num, M is output box number, and the 3rd dimension"
"batch num, M is output box number, and the 3rd dimension
"
"stores [xmin, ymin, xmax, ymax] coordinates of boxes."
);
"stores [xmin, ymin, xmax, ymax] coordinates of boxes."
);
AddOutput
(
"Scores"
,
AddOutput
(
"Scores"
,
"The output tensor ofdetection boxes scores of YoloBox"
"The output tensor ofdetection boxes scores of YoloBox
"
"operator, This is a 3-D tensor with shape of [N, M, C],"
"operator, This is a 3-D tensor with shape of [N, M, C],
"
"N is the batch num, M is output box number, C is the"
"N is the batch num, M is output box number, C is the
"
"class number."
);
"class number."
);
AddAttr
<
int
>
(
"class_num"
,
"The number of classes to predict."
);
AddAttr
<
int
>
(
"class_num"
,
"The number of classes to predict."
);
...
@@ -107,30 +107,31 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -107,30 +107,31 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
"and thrid YoloBox operators."
)
"and thrid YoloBox operators."
)
.
SetDefault
(
32
);
.
SetDefault
(
32
);
AddAttr
<
float
>
(
"conf_thresh"
,
AddAttr
<
float
>
(
"conf_thresh"
,
"The confidence scores threshold of detection boxes."
"The confidence scores threshold of detection boxes.
"
"
boxes with confidence scores under threshold should
"
"
Boxes with confidence scores under threshold should
"
"be ignored."
)
"be ignored."
)
.
SetDefault
(
0.01
);
.
SetDefault
(
0.01
);
AddComment
(
R"DOC(
AddComment
(
R"DOC(
This operator generate YOLO detection boxes from output of YOLOv3 network.
This operator generate YOLO detection boxes from output of YOLOv3 network.
The output of previous network is in shape [N, C, H, W], while H and W
The output of previous network is in shape [N, C, H, W], while H and W
should be the same, specify the grid size, each grid point predict given
should be the same, H and W specify the grid size, each grid point predict
number boxes, this given number is specified by anchors, it should be
given number boxes, this given number, which following will be represented as S,
half anchors length, which following will be represented as S. In the
is specified by the number of anchors, In the second dimension(the channel
second dimension(the channel dimension), C should be S * (class_num + 5),
dimension), C should be equal to S * (class_num + 5), class_num is the object
class_num is the box categoriy number of source dataset(such as coco),
category number of source dataset(such as 80 in coco dataset), so in the
so in the second dimension, stores 4 box location coordinates x, y, w, h
second(channel) dimension, apart from 4 box location coordinates x, y, w, h,
and confidence score of the box and class one-hot key of each anchor box.
also includes confidence score of the box and class one-hot key of each anchor
box.
While the 4 location coordinates if :math:`tx, ty, tw, th`, the box
predictions correspnd to:
Assume the 4 location coordinates are :math:`t_x, t_y, t_w, t_h`, the box
predictions should be as follows:
$$
$$
b_x = \sigma(t_x) + c_x
b_x = \
\
sigma(t_x) + c_x
$$
$$
$$
$$
b_y = \sigma(t_y) + c_y
b_y = \
\
sigma(t_y) + c_y
$$
$$
$$
$$
b_w = p_w e^{t_w}
b_w = p_w e^{t_w}
...
@@ -139,14 +140,14 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
...
@@ -139,14 +140,14 @@ class YoloBoxOpMaker : public framework::OpProtoAndCheckerMaker {
b_h = p_h e^{t_h}
b_h = p_h e^{t_h}
$$
$$
While :math:`c_x, c_y` is the left top corner of current grid and
in the equation above, :math:`c_x, c_y` is the left top corner of current grid
:math:`p_w, p_h` is specified by anchors.
and
:math:`p_w, p_h` is specified by anchors.
The logistic
scores
of the 5rd channel of each anchor prediction boxes
The logistic
regression value
of the 5rd channel of each anchor prediction boxes
represent the confidence score of each prediction
scores
, and the logistic
represent the confidence score of each prediction
box
, and the logistic
scores of the last class_num channels of each anchor prediction boxes
regression value of the last :attr:`class_num` channels of each anchor prediction
represent the classifcation scores. Boxes with confidence scores less than
boxes
represent the classifcation scores. Boxes with confidence scores less than
conf_thresh
should be ignored, and box final scores is the product of
:attr:`conf_thresh`
should be ignored, and box final scores is the product of
confidence scores and classification scores.
confidence scores and classification scores.
)DOC"
);
)DOC"
);
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
abb5a9c7
...
@@ -628,10 +628,12 @@ def yolo_box(x,
...
@@ -628,10 +628,12 @@ def yolo_box(x,
class_num (int): ${class_num_comment}
class_num (int): ${class_num_comment}
conf_thresh (float): ${conf_thresh_comment}
conf_thresh (float): ${conf_thresh_comment}
downsample_ratio (int): ${downsample_ratio_comment}
downsample_ratio (int): ${downsample_ratio_comment}
name (string): the name of yolo
v3 loss
name (string): the name of yolo
box layer
Returns:
Returns:
Variable: A 1-D tensor with shape [1], the value of yolov3 loss
Variable: A 3-D tensor with shape [N, M, 4], the coordinates of boxes,
and a 3-D tensor with shape [N, M, C], the classification scores
of boxes.
Raises:
Raises:
TypeError: Input x of yolov_box must be Variable
TypeError: Input x of yolov_box must be Variable
...
@@ -640,6 +642,7 @@ def yolo_box(x,
...
@@ -640,6 +642,7 @@ def yolo_box(x,
TypeError: Attr conf_thresh of yolo box must be a float number
TypeError: Attr conf_thresh of yolo box must be a float number
Examples:
Examples:
.. code-block:: python
.. code-block:: python
x = fluid.layers.data(name='x', shape=[255, 13, 13], dtype='float32')
x = fluid.layers.data(name='x', shape=[255, 13, 13], dtype='float32')
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录