Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OPTHREE
Paddle
提交
b62a17bb
P
Paddle
项目概览
OPTHREE
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b62a17bb
编写于
1月 18, 2019
作者:
J
jerrywgz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add nms api
上级
f660553d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
50 addition
and
4 deletion
+50
-4
paddle/fluid/operators/detection/multiclass_nms_op.cc
paddle/fluid/operators/detection/multiclass_nms_op.cc
+4
-4
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+35
-0
python/paddle/fluid/tests/test_detection.py
python/paddle/fluid/tests/test_detection.py
+11
-0
未找到文件。
paddle/fluid/operators/detection/multiclass_nms_op.cc
浏览文件 @
b62a17bb
...
...
@@ -458,7 +458,8 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker {
"predicted locations of M bounding bboxes, N is the batch size. "
"Each bounding box has four coordinate values and the layout is "
"[xmin, ymin, xmax, ymax], when box size equals to 4."
"2. (LoDTensor) A 3-D Tensor with shape [N, M, 4]"
);
"2. (LoDTensor) A 3-D Tensor with shape [N, M, 4]"
"N is the number of boxes, M is the class number"
);
AddInput
(
"Scores"
,
"Two types of scores are supported:"
"1. (Tensor) A 3-D Tensor with shape [N, C, M] represents the "
...
...
@@ -467,8 +468,7 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker {
"there are total M scores which corresponding M bounding boxes. "
" Please note, M is equal to the 1st dimension of BBoxes. "
"2. (LoDTensor) A 2-D LoDTensor with shape"
"[N, num_class]. N is the number of bbox and"
"M represents the scores of bboxes in each class."
);
"[N, num_class]. N is the number of bbox"
);
AddAttr
<
int
>
(
"background_label"
,
"(int, defalut: 0) "
...
...
@@ -497,7 +497,7 @@ class MultiClassNMSOpMaker : public framework::OpProtoAndCheckerMaker {
"Number of total bboxes to be kept per image after NMS "
"step. -1 means keeping all bboxes after NMS step."
);
AddAttr
<
bool
>
(
"normalized"
,
"(bool, default
fals
e) "
"(bool, default
tru
e) "
"Whether detections are normalized."
)
.
SetDefault
(
true
);
AddOutput
(
"Out"
,
...
...
python/paddle/fluid/layers/detection.py
浏览文件 @
b62a17bb
...
...
@@ -48,6 +48,7 @@ __all__ = [
'box_coder'
,
'polygon_box_transform'
,
'yolov3_loss'
,
'multiclass_nms'
,
]
...
...
@@ -1810,3 +1811,37 @@ def generate_proposals(scores,
rpn_roi_probs
.
stop_gradient
=
True
return
rpn_rois
,
rpn_roi_probs
def
multiclass_nms
(
bboxes
,
scores
,
score_threshold
,
nms_top_k
,
nms_threshold
,
keep_top_k
,
normalized
=
True
,
nms_eta
=
1.
,
background_label
=
0
):
"""
"""
helper
=
LayerHelper
(
'multiclass_nms'
,
**
locals
())
output
=
helper
.
create_variable_for_type_inference
(
dtype
=
bboxes
.
dtype
)
helper
.
append_op
(
type
=
"multiclass_nms"
,
inputs
=
{
'BBoxes'
:
bboxes
,
'Scores'
:
scores
},
attrs
=
{
'background_label'
:
background_label
,
'score_threshold'
:
score_threshold
,
'nms_top_k'
:
nms_top_k
,
'nms_threshold'
:
nms_threshold
,
'nms_eta'
:
nms_eta
,
'keep_top_k'
:
keep_top_k
,
'nms_eta'
:
nms_eta
,
'normalized'
:
normalized
},
outputs
=
{
'Out'
:
output
})
output
.
stop_gradient
=
True
return
output
python/paddle/fluid/tests/test_detection.py
浏览文件 @
b62a17bb
...
...
@@ -401,5 +401,16 @@ class TestYoloDetection(unittest.TestCase):
self
.
assertIsNotNone
(
loss
)
class
TestMulticlassNMS
(
unittest
.
TestCase
):
def
test_multiclass_nms
(
self
):
program
=
Program
()
with
program_guard
(
program
):
bboxes
=
layers
.
data
(
name
=
'bboxes'
,
shape
=
[
-
1
,
10
,
4
],
dtype
=
'float32'
)
scores
=
layers
.
data
(
name
=
'scores'
,
shape
=
[
-
1
,
10
],
dtype
=
'float32'
)
output
=
layers
.
multiclass_nms
(
bboxes
,
scores
,
0.3
,
400
,
0.7
,
200
)
self
.
assertIsNotNone
(
output
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录