Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
d409ec06
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
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看板
未验证
提交
d409ec06
编写于
7月 04, 2022
作者:
W
Wenyu
提交者:
GitHub
7月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade cascade model (#6346)
* add reg_class_agnostic * add loss_rpn_bbox
上级
35156f31
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
4 deletion
+23
-4
ppdet/modeling/heads/cascade_head.py
ppdet/modeling/heads/cascade_head.py
+13
-2
ppdet/modeling/proposal_generator/rpn_head.py
ppdet/modeling/proposal_generator/rpn_head.py
+10
-2
未找到文件。
ppdet/modeling/heads/cascade_head.py
浏览文件 @
d409ec06
...
...
@@ -160,7 +160,8 @@ class CascadeHead(BBoxHead):
bbox_weight
=
[[
10.
,
10.
,
5.
,
5.
],
[
20.0
,
20.0
,
10.0
,
10.0
],
[
30.0
,
30.0
,
15.0
,
15.0
]],
num_cascade_stages
=
3
,
bbox_loss
=
None
):
bbox_loss
=
None
,
reg_class_agnostic
=
True
):
nn
.
Layer
.
__init__
(
self
,
)
self
.
head
=
head
self
.
roi_extractor
=
roi_extractor
...
...
@@ -173,6 +174,9 @@ class CascadeHead(BBoxHead):
self
.
num_cascade_stages
=
num_cascade_stages
self
.
bbox_loss
=
bbox_loss
self
.
reg_class_agnostic
=
reg_class_agnostic
num_bbox_delta
=
4
if
reg_class_agnostic
else
4
*
num_classes
self
.
bbox_score_list
=
[]
self
.
bbox_delta_list
=
[]
for
i
in
range
(
num_cascade_stages
):
...
...
@@ -190,7 +194,7 @@ class CascadeHead(BBoxHead):
delta_name
,
nn
.
Linear
(
in_channel
,
4
,
num_bbox_delta
,
weight_attr
=
paddle
.
ParamAttr
(
initializer
=
Normal
(
mean
=
0.0
,
std
=
0.001
))))
self
.
bbox_score_list
.
append
(
bbox_score
)
...
...
@@ -227,6 +231,13 @@ class CascadeHead(BBoxHead):
bbox_feat
=
self
.
head
(
rois_feat
,
i
)
scores
=
self
.
bbox_score_list
[
i
](
bbox_feat
)
deltas
=
self
.
bbox_delta_list
[
i
](
bbox_feat
)
# TODO (lyuwenyu) Is it correct for only one class ?
if
not
self
.
reg_class_agnostic
and
i
<
self
.
num_cascade_stages
-
1
:
deltas
=
deltas
.
reshape
([
-
1
,
self
.
num_classes
,
4
])
labels
=
scores
[:,
:
-
1
].
argmax
(
axis
=-
1
)
deltas
=
deltas
[
paddle
.
arange
(
deltas
.
shape
[
0
]),
labels
]
head_out_list
.
append
([
scores
,
deltas
,
rois
])
pred_bbox
=
self
.
_get_pred_bbox
(
deltas
,
rois
,
self
.
bbox_weight
[
i
])
...
...
ppdet/modeling/proposal_generator/rpn_head.py
浏览文件 @
d409ec06
...
...
@@ -68,6 +68,7 @@ class RPNHead(nn.Layer):
derived by from_config
"""
__shared__
=
[
'export_onnx'
]
__inject__
=
[
'loss_rpn_bbox'
]
def
__init__
(
self
,
anchor_generator
=
_get_class_default_kwargs
(
AnchorGenerator
),
...
...
@@ -76,7 +77,8 @@ class RPNHead(nn.Layer):
12000
,
2000
),
test_proposal
=
_get_class_default_kwargs
(
ProposalGenerator
),
in_channel
=
1024
,
export_onnx
=
False
):
export_onnx
=
False
,
loss_rpn_bbox
=
None
):
super
(
RPNHead
,
self
).
__init__
()
self
.
anchor_generator
=
anchor_generator
self
.
rpn_target_assign
=
rpn_target_assign
...
...
@@ -91,6 +93,7 @@ class RPNHead(nn.Layer):
self
.
train_proposal
=
ProposalGenerator
(
**
train_proposal
)
if
isinstance
(
test_proposal
,
dict
):
self
.
test_proposal
=
ProposalGenerator
(
**
test_proposal
)
self
.
loss_rpn_bbox
=
loss_rpn_bbox
num_anchors
=
self
.
anchor_generator
.
num_anchors
self
.
rpn_feat
=
RPNFeat
(
in_channel
,
in_channel
)
...
...
@@ -298,7 +301,12 @@ class RPNHead(nn.Layer):
loc_tgt
=
paddle
.
concat
(
loc_tgt
)
loc_tgt
=
paddle
.
gather
(
loc_tgt
,
pos_ind
)
loc_tgt
.
stop_gradient
=
True
loss_rpn_reg
=
paddle
.
abs
(
loc_pred
-
loc_tgt
).
sum
()
if
self
.
loss_rpn_bbox
is
None
:
loss_rpn_reg
=
paddle
.
abs
(
loc_pred
-
loc_tgt
).
sum
()
else
:
loss_rpn_reg
=
self
.
loss_rpn_bbox
(
loc_pred
,
loc_tgt
).
sum
()
return
{
'loss_rpn_cls'
:
loss_rpn_cls
/
norm
,
'loss_rpn_reg'
:
loss_rpn_reg
/
norm
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录