Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
75e3def5
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
75e3def5
编写于
5月 28, 2021
作者:
C
cnn
提交者:
GitHub
5月 28, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[dev] rcnn support bs>1 (#3174)
* rcnn bs>1 * delete redundant comments
上级
fa6c5a11
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
16 deletion
+18
-16
ppdet/modeling/layers.py
ppdet/modeling/layers.py
+5
-1
ppdet/modeling/post_process.py
ppdet/modeling/post_process.py
+10
-6
ppdet/modeling/proposal_generator/rpn_head.py
ppdet/modeling/proposal_generator/rpn_head.py
+3
-9
未找到文件。
ppdet/modeling/layers.py
浏览文件 @
75e3def5
...
...
@@ -342,7 +342,11 @@ class RCNNBox(object):
origin_shape
=
paddle
.
floor
(
im_shape
/
scale_factor
+
0.5
)
scale_list
=
[]
origin_shape_list
=
[]
for
idx
,
roi_per_im
in
enumerate
(
roi
):
batch_size
=
paddle
.
slice
(
paddle
.
shape
(
im_shape
),
[
0
],
[
0
],
[
1
])
# bbox_pred.shape: [N, C*4]
for
idx
in
range
(
batch_size
):
roi_per_im
=
roi
[
idx
]
rois_num_per_im
=
rois_num
[
idx
]
expand_im_shape
=
paddle
.
expand
(
im_shape
[
idx
,
:],
[
rois_num_per_im
,
2
])
...
...
ppdet/modeling/post_process.py
浏览文件 @
75e3def5
...
...
@@ -35,7 +35,7 @@ __all__ = [
@
register
class
BBoxPostProcess
(
object
):
class
BBoxPostProcess
(
nn
.
Layer
):
__shared__
=
[
'num_classes'
]
__inject__
=
[
'decode'
,
'nms'
]
...
...
@@ -44,8 +44,14 @@ class BBoxPostProcess(object):
self
.
num_classes
=
num_classes
self
.
decode
=
decode
self
.
nms
=
nms
self
.
fake_bboxes
=
paddle
.
to_tensor
(
np
.
array
(
[[
-
1
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
]],
dtype
=
'float32'
))
self
.
fake_bbox_num
=
paddle
.
to_tensor
(
np
.
array
([
1
],
dtype
=
'int32'
))
def
__call__
(
self
,
head_out
,
rois
,
im_shape
,
scale_factor
):
def
forward
(
self
,
head_out
,
rois
,
im_shape
,
scale_factor
):
"""
Decode the bbox and do NMS if needed.
...
...
@@ -90,10 +96,8 @@ class BBoxPostProcess(object):
"""
if
bboxes
.
shape
[
0
]
==
0
:
bboxes
=
paddle
.
to_tensor
(
np
.
array
(
[[
-
1
,
0.0
,
0.0
,
0.0
,
0.0
,
0.0
]],
dtype
=
'float32'
))
bbox_num
=
paddle
.
to_tensor
(
np
.
array
([
1
],
dtype
=
'int32'
))
bboxes
=
self
.
fake_bboxes
bbox_num
=
self
.
fake_bbox_num
origin_shape
=
paddle
.
floor
(
im_shape
/
scale_factor
+
0.5
)
...
...
ppdet/modeling/proposal_generator/rpn_head.py
浏览文件 @
75e3def5
...
...
@@ -133,21 +133,14 @@ class RPNHead(nn.Layer):
anchors
=
self
.
anchor_generator
(
rpn_feats
)
# TODO: Fix batch_size > 1 when testing.
if
self
.
training
:
batch_size
=
inputs
[
'im_shape'
].
shape
[
0
]
else
:
batch_size
=
1
rois
,
rois_num
=
self
.
_gen_proposal
(
scores
,
deltas
,
anchors
,
inputs
,
batch_size
)
rois
,
rois_num
=
self
.
_gen_proposal
(
scores
,
deltas
,
anchors
,
inputs
)
if
self
.
training
:
loss
=
self
.
get_loss
(
scores
,
deltas
,
anchors
,
inputs
)
return
rois
,
rois_num
,
loss
else
:
return
rois
,
rois_num
,
None
def
_gen_proposal
(
self
,
scores
,
bbox_deltas
,
anchors
,
inputs
,
batch_size
):
def
_gen_proposal
(
self
,
scores
,
bbox_deltas
,
anchors
,
inputs
):
"""
scores (list[Tensor]): Multi-level scores prediction
bbox_deltas (list[Tensor]): Multi-level deltas prediction
...
...
@@ -161,6 +154,7 @@ class RPNHead(nn.Layer):
# Get 'topk' of them as final output
bs_rois_collect
=
[]
bs_rois_num_collect
=
[]
batch_size
=
paddle
.
slice
(
paddle
.
shape
(
im_shape
),
[
0
],
[
0
],
[
1
])
# Generate proposals for each level and each batch.
# Discard batch-computing to avoid sorting bbox cross different batches.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录