Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
d409ec06
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
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):
...
@@ -160,7 +160,8 @@ class CascadeHead(BBoxHead):
bbox_weight
=
[[
10.
,
10.
,
5.
,
5.
],
[
20.0
,
20.0
,
10.0
,
10.0
],
bbox_weight
=
[[
10.
,
10.
,
5.
,
5.
],
[
20.0
,
20.0
,
10.0
,
10.0
],
[
30.0
,
30.0
,
15.0
,
15.0
]],
[
30.0
,
30.0
,
15.0
,
15.0
]],
num_cascade_stages
=
3
,
num_cascade_stages
=
3
,
bbox_loss
=
None
):
bbox_loss
=
None
,
reg_class_agnostic
=
True
):
nn
.
Layer
.
__init__
(
self
,
)
nn
.
Layer
.
__init__
(
self
,
)
self
.
head
=
head
self
.
head
=
head
self
.
roi_extractor
=
roi_extractor
self
.
roi_extractor
=
roi_extractor
...
@@ -173,6 +174,9 @@ class CascadeHead(BBoxHead):
...
@@ -173,6 +174,9 @@ class CascadeHead(BBoxHead):
self
.
num_cascade_stages
=
num_cascade_stages
self
.
num_cascade_stages
=
num_cascade_stages
self
.
bbox_loss
=
bbox_loss
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_score_list
=
[]
self
.
bbox_delta_list
=
[]
self
.
bbox_delta_list
=
[]
for
i
in
range
(
num_cascade_stages
):
for
i
in
range
(
num_cascade_stages
):
...
@@ -190,7 +194,7 @@ class CascadeHead(BBoxHead):
...
@@ -190,7 +194,7 @@ class CascadeHead(BBoxHead):
delta_name
,
delta_name
,
nn
.
Linear
(
nn
.
Linear
(
in_channel
,
in_channel
,
4
,
num_bbox_delta
,
weight_attr
=
paddle
.
ParamAttr
(
initializer
=
Normal
(
weight_attr
=
paddle
.
ParamAttr
(
initializer
=
Normal
(
mean
=
0.0
,
std
=
0.001
))))
mean
=
0.0
,
std
=
0.001
))))
self
.
bbox_score_list
.
append
(
bbox_score
)
self
.
bbox_score_list
.
append
(
bbox_score
)
...
@@ -227,6 +231,13 @@ class CascadeHead(BBoxHead):
...
@@ -227,6 +231,13 @@ class CascadeHead(BBoxHead):
bbox_feat
=
self
.
head
(
rois_feat
,
i
)
bbox_feat
=
self
.
head
(
rois_feat
,
i
)
scores
=
self
.
bbox_score_list
[
i
](
bbox_feat
)
scores
=
self
.
bbox_score_list
[
i
](
bbox_feat
)
deltas
=
self
.
bbox_delta_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
])
head_out_list
.
append
([
scores
,
deltas
,
rois
])
pred_bbox
=
self
.
_get_pred_bbox
(
deltas
,
rois
,
self
.
bbox_weight
[
i
])
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):
...
@@ -68,6 +68,7 @@ class RPNHead(nn.Layer):
derived by from_config
derived by from_config
"""
"""
__shared__
=
[
'export_onnx'
]
__shared__
=
[
'export_onnx'
]
__inject__
=
[
'loss_rpn_bbox'
]
def
__init__
(
self
,
def
__init__
(
self
,
anchor_generator
=
_get_class_default_kwargs
(
AnchorGenerator
),
anchor_generator
=
_get_class_default_kwargs
(
AnchorGenerator
),
...
@@ -76,7 +77,8 @@ class RPNHead(nn.Layer):
...
@@ -76,7 +77,8 @@ class RPNHead(nn.Layer):
12000
,
2000
),
12000
,
2000
),
test_proposal
=
_get_class_default_kwargs
(
ProposalGenerator
),
test_proposal
=
_get_class_default_kwargs
(
ProposalGenerator
),
in_channel
=
1024
,
in_channel
=
1024
,
export_onnx
=
False
):
export_onnx
=
False
,
loss_rpn_bbox
=
None
):
super
(
RPNHead
,
self
).
__init__
()
super
(
RPNHead
,
self
).
__init__
()
self
.
anchor_generator
=
anchor_generator
self
.
anchor_generator
=
anchor_generator
self
.
rpn_target_assign
=
rpn_target_assign
self
.
rpn_target_assign
=
rpn_target_assign
...
@@ -91,6 +93,7 @@ class RPNHead(nn.Layer):
...
@@ -91,6 +93,7 @@ class RPNHead(nn.Layer):
self
.
train_proposal
=
ProposalGenerator
(
**
train_proposal
)
self
.
train_proposal
=
ProposalGenerator
(
**
train_proposal
)
if
isinstance
(
test_proposal
,
dict
):
if
isinstance
(
test_proposal
,
dict
):
self
.
test_proposal
=
ProposalGenerator
(
**
test_proposal
)
self
.
test_proposal
=
ProposalGenerator
(
**
test_proposal
)
self
.
loss_rpn_bbox
=
loss_rpn_bbox
num_anchors
=
self
.
anchor_generator
.
num_anchors
num_anchors
=
self
.
anchor_generator
.
num_anchors
self
.
rpn_feat
=
RPNFeat
(
in_channel
,
in_channel
)
self
.
rpn_feat
=
RPNFeat
(
in_channel
,
in_channel
)
...
@@ -298,7 +301,12 @@ class RPNHead(nn.Layer):
...
@@ -298,7 +301,12 @@ class RPNHead(nn.Layer):
loc_tgt
=
paddle
.
concat
(
loc_tgt
)
loc_tgt
=
paddle
.
concat
(
loc_tgt
)
loc_tgt
=
paddle
.
gather
(
loc_tgt
,
pos_ind
)
loc_tgt
=
paddle
.
gather
(
loc_tgt
,
pos_ind
)
loc_tgt
.
stop_gradient
=
True
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
{
return
{
'loss_rpn_cls'
:
loss_rpn_cls
/
norm
,
'loss_rpn_cls'
:
loss_rpn_cls
/
norm
,
'loss_rpn_reg'
:
loss_rpn_reg
/
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录