Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f4932680
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看板
未验证
提交
f4932680
编写于
4月 28, 2020
作者:
F
FDInSky
提交者:
GitHub
4月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix generate_proposals (#23797) (#24225)
* test=develop fix generate_proposals
上级
28fa467b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
41 addition
and
6 deletion
+41
-6
python/paddle/fluid/layers/detection.py
python/paddle/fluid/layers/detection.py
+10
-3
python/paddle/fluid/tests/test_detection.py
python/paddle/fluid/tests/test_detection.py
+1
-1
python/paddle/fluid/tests/unittests/test_generate_proposals_op.py
...addle/fluid/tests/unittests/test_generate_proposals_op.py
+30
-2
未找到文件。
python/paddle/fluid/layers/detection.py
浏览文件 @
f4932680
...
@@ -2742,7 +2742,8 @@ def generate_proposals(scores,
...
@@ -2742,7 +2742,8 @@ def generate_proposals(scores,
nms_thresh
=
0.5
,
nms_thresh
=
0.5
,
min_size
=
0.1
,
min_size
=
0.1
,
eta
=
1.0
,
eta
=
1.0
,
name
=
None
):
name
=
None
,
return_rois_num
=
False
):
"""
"""
**Generate proposal Faster-RCNN**
**Generate proposal Faster-RCNN**
...
@@ -2789,7 +2790,10 @@ def generate_proposals(scores,
...
@@ -2789,7 +2790,10 @@ def generate_proposals(scores,
width < min_size. The data type must be float32. `0.1` by default.
width < min_size. The data type must be float32. `0.1` by default.
eta(float): Apply in adaptive NMS, if adaptive `threshold > 0.5`,
eta(float): Apply in adaptive NMS, if adaptive `threshold > 0.5`,
`adaptive_threshold = adaptive_threshold * eta` in each iteration.
`adaptive_threshold = adaptive_threshold * eta` in each iteration.
return_rois_num(bool): When setting True, it will return a 1D Tensor with shape [N, ] that includes Rois's
num of each image in one batch. The N is the image's num. For example, the tensor has values [4,5] that represents
the first image has 4 Rois, the second image has 5 Rois. It only used in rcnn model.
'False' by default.
Returns:
Returns:
tuple:
tuple:
A tuple with format ``(rpn_rois, rpn_roi_probs)``.
A tuple with format ``(rpn_rois, rpn_roi_probs)``.
...
@@ -2843,7 +2847,10 @@ def generate_proposals(scores,
...
@@ -2843,7 +2847,10 @@ def generate_proposals(scores,
rpn_roi_probs
.
stop_gradient
=
True
rpn_roi_probs
.
stop_gradient
=
True
rpn_rois_lod
.
stop_gradient
=
True
rpn_rois_lod
.
stop_gradient
=
True
return
rpn_rois
,
rpn_roi_probs
,
rpn_rois_lod
if
return_rois_num
:
return
rpn_rois
,
rpn_roi_probs
,
rpn_rois_lod
else
:
return
rpn_rois
,
rpn_roi_probs
def
box_clip
(
input
,
im_info
,
name
=
None
):
def
box_clip
(
input
,
im_info
,
name
=
None
):
...
...
python/paddle/fluid/tests/test_detection.py
浏览文件 @
f4932680
...
@@ -480,7 +480,7 @@ class TestGenerateProposals(unittest.TestCase):
...
@@ -480,7 +480,7 @@ class TestGenerateProposals(unittest.TestCase):
name
=
'bbox_deltas'
,
name
=
'bbox_deltas'
,
shape
=
[
num_anchors
*
4
,
8
,
8
],
shape
=
[
num_anchors
*
4
,
8
,
8
],
dtype
=
'float32'
)
dtype
=
'float32'
)
rpn_rois
,
rpn_roi_probs
,
_
=
fluid
.
layers
.
generate_proposals
(
rpn_rois
,
rpn_roi_probs
=
fluid
.
layers
.
generate_proposals
(
name
=
'generate_proposals'
,
name
=
'generate_proposals'
,
scores
=
scores
,
scores
=
scores
,
bbox_deltas
=
bbox_deltas
,
bbox_deltas
=
bbox_deltas
,
...
...
python/paddle/fluid/tests/unittests/test_generate_proposals_op.py
浏览文件 @
f4932680
...
@@ -282,8 +282,6 @@ class TestGenerateProposalsOp(OpTest):
...
@@ -282,8 +282,6 @@ class TestGenerateProposalsOp(OpTest):
self
.
outputs
=
{
self
.
outputs
=
{
'RpnRois'
:
(
self
.
rpn_rois
[
0
],
[
self
.
lod
]),
'RpnRois'
:
(
self
.
rpn_rois
[
0
],
[
self
.
lod
]),
'RpnRoiProbs'
:
(
self
.
rpn_roi_probs
[
0
],
[
self
.
lod
]),
'RpnRoiProbs'
:
(
self
.
rpn_roi_probs
[
0
],
[
self
.
lod
]),
'RpnRoisLod'
:
(
np
.
asarray
(
self
.
lod
,
dtype
=
np
.
int32
))
}
}
def
test_check_output
(
self
):
def
test_check_output
(
self
):
...
@@ -328,5 +326,35 @@ class TestGenerateProposalsOp(OpTest):
...
@@ -328,5 +326,35 @@ class TestGenerateProposalsOp(OpTest):
self
.
nms_thresh
,
self
.
min_size
,
self
.
eta
)
self
.
nms_thresh
,
self
.
min_size
,
self
.
eta
)
class
TestGenerateProposalsOutLodOp
(
TestGenerateProposalsOp
):
def
set_data
(
self
):
self
.
init_test_params
()
self
.
init_test_input
()
self
.
init_test_output
()
self
.
inputs
=
{
'Scores'
:
self
.
scores
,
'BboxDeltas'
:
self
.
bbox_deltas
,
'ImInfo'
:
self
.
im_info
.
astype
(
np
.
float32
),
'Anchors'
:
self
.
anchors
,
'Variances'
:
self
.
variances
}
self
.
attrs
=
{
'pre_nms_topN'
:
self
.
pre_nms_topN
,
'post_nms_topN'
:
self
.
post_nms_topN
,
'nms_thresh'
:
self
.
nms_thresh
,
'min_size'
:
self
.
min_size
,
'eta'
:
self
.
eta
,
'return_rois_num'
:
True
}
self
.
outputs
=
{
'RpnRois'
:
(
self
.
rpn_rois
[
0
],
[
self
.
lod
]),
'RpnRoiProbs'
:
(
self
.
rpn_roi_probs
[
0
],
[
self
.
lod
]),
'RpnRoisLod'
:
(
np
.
asarray
(
self
.
lod
,
dtype
=
np
.
int32
))
}
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录