Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4161328e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
4161328e
编写于
2月 26, 2018
作者:
W
wanghaox
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add warrper for detection map operator
上级
1924aa14
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
78 addition
and
0 deletion
+78
-0
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+40
-0
python/paddle/fluid/tests/test_detection.py
python/paddle/fluid/tests/test_detection.py
+38
-0
未找到文件。
python/paddle/fluid/layers/detection.py
浏览文件 @
4161328e
...
@@ -16,6 +16,7 @@ All layers just related to the detection neural network.
...
@@ -16,6 +16,7 @@ All layers just related to the detection neural network.
"""
"""
from
layer_function_generator
import
generate_layer_fn
from
layer_function_generator
import
generate_layer_fn
from
layer_function_generator
import
autodoc
from
..layer_helper
import
LayerHelper
from
..layer_helper
import
LayerHelper
import
tensor
import
tensor
import
ops
import
ops
...
@@ -28,6 +29,7 @@ __all__ = [
...
@@ -28,6 +29,7 @@ __all__ = [
'target_assign'
,
'target_assign'
,
'detection_output'
,
'detection_output'
,
'ssd_loss'
,
'ssd_loss'
,
'detection_map'
,
]
]
__auto__
=
[
__auto__
=
[
...
@@ -132,6 +134,44 @@ def detection_output(scores,
...
@@ -132,6 +134,44 @@ def detection_output(scores,
return
nmsed_outs
return
nmsed_outs
@
autodoc
()
def
detection_map
(
detect_res
,
label
,
pos_count
=
None
,
true_pos
=
None
,
false_pos
=
None
,
overlap_threshold
=
0.3
,
evaluate_difficult
=
True
,
ap_type
=
'integral'
):
helper
=
LayerHelper
(
"detection_map"
,
**
locals
())
map_out
=
helper
.
create_tmp_variable
(
dtype
=
'float32'
)
accum_pos_count_out
=
helper
.
create_tmp_variable
(
dtype
=
'int32'
)
accum_true_pos_out
=
helper
.
create_tmp_variable
(
dtype
=
'float32'
)
accum_false_pos_out
=
helper
.
create_tmp_variable
(
dtype
=
'float32'
)
helper
.
append_op
(
type
=
"detection_map"
,
inputs
=
{
'Label'
:
label
,
'DetectRes'
:
detect_res
,
'PosCount'
:
pos_count
,
'TruePos'
:
true_pos
,
'FalsePos'
:
false_pos
},
outputs
=
{
'MAP'
:
map_out
,
'AccumPosCount'
:
accum_pos_count_out
,
'AccumTruePos'
:
accum_true_pos_out
,
'AccumFalsePos'
:
accum_false_pos_out
},
attrs
=
{
'overlap_threshold'
:
overlap_threshold
,
'evaluate_difficult'
:
evaluate_difficult
,
'ap_type'
:
ap_type
})
return
map_out
,
accum_pos_count_out
,
accum_true_pos_out
,
accum_false_pos_out
def
bipartite_match
(
dist_matrix
,
name
=
None
):
def
bipartite_match
(
dist_matrix
,
name
=
None
):
"""
"""
**Bipartite matchint operator**
**Bipartite matchint operator**
...
...
python/paddle/fluid/tests/test_detection.py
浏览文件 @
4161328e
...
@@ -145,5 +145,43 @@ class TestMultiBoxHead(unittest.TestCase):
...
@@ -145,5 +145,43 @@ class TestMultiBoxHead(unittest.TestCase):
return
mbox_locs
,
mbox_confs
,
box
,
var
return
mbox_locs
,
mbox_confs
,
box
,
var
class
TestDetectionMAP
(
unittest
.
TestCase
):
def
test_detection_map
(
self
):
program
=
Program
()
with
program_guard
(
program
):
detect_res
=
layers
.
data
(
name
=
'detect_res'
,
shape
=
[
10
,
6
],
append_batch_size
=
False
,
dtype
=
'float32'
)
label
=
layers
.
data
(
name
=
'label'
,
shape
=
[
10
,
6
],
append_batch_size
=
False
,
dtype
=
'float32'
)
map_out
,
accum_pos_count_out
,
accum_true_pos_out
,
accum_false_pos_out
=
layers
.
detection_map
(
detect_res
=
detect_res
,
label
=
label
)
self
.
assertIsNotNone
(
map_out
)
self
.
assertIsNotNone
(
accum_pos_count_out
)
self
.
assertIsNotNone
(
accum_true_pos_out
)
self
.
assertIsNotNone
(
accum_false_pos_out
)
self
.
assertEqual
(
map_out
.
shape
,
(
1
,
))
map_out
,
accum_pos_count_out2
,
accum_true_pos_out2
,
accum_false_pos_out2
=
layers
.
detection_map
(
detect_res
=
detect_res
,
label
=
label
)
self
.
assertIsNotNone
(
map_out
)
self
.
assertIsNotNone
(
accum_pos_count_out2
)
self
.
assertIsNotNone
(
accum_true_pos_out2
)
self
.
assertIsNotNone
(
accum_false_pos_out2
)
self
.
assertEqual
(
map_out
.
shape
,
(
1
,
))
self
.
assertEqual
(
accum_pos_count_out
.
shape
,
accum_pos_count_out2
.
shape
)
self
.
assertEqual
(
accum_true_pos_out
.
shape
,
accum_true_pos_out2
.
shape
)
self
.
assertEqual
(
accum_false_pos_out
.
shape
,
accum_false_pos_out2
.
shape
)
print
(
str
(
program
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录