Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
c27233d3
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看板
未验证
提交
c27233d3
编写于
3月 07, 2022
作者:
G
Guanghua Yu
提交者:
GitHub
3月 07, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix picodetv2 post process (#5306)
上级
a4e093b7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
23 deletion
+36
-23
ppdet/modeling/heads/pico_head.py
ppdet/modeling/heads/pico_head.py
+36
-23
未找到文件。
ppdet/modeling/heads/pico_head.py
浏览文件 @
c27233d3
...
...
@@ -460,18 +460,15 @@ class PicoHeadV2(GFLHead):
act
=
self
.
act
,
use_act_in_out
=
False
))
def
forward
(
self
,
fpn_feats
,
deploy
=
Fals
e
):
def
forward
(
self
,
fpn_feats
,
export_post_process
=
Tru
e
):
assert
len
(
fpn_feats
)
==
len
(
self
.
fpn_stride
),
"The size of fpn_feats is not equal to size of fpn_stride"
anchors
,
_
,
num_anchors_list
,
stride_tensor_list
=
generate_anchors_for_grid_cell
(
fpn_feats
,
self
.
fpn_stride
,
self
.
grid_cell_scale
,
self
.
cell_offset
)
anchors_split
=
paddle
.
split
(
anchors
,
num_anchors_list
)
cls_score_list
,
reg_list
,
box_list
=
[],
[],
[]
for
i
,
fpn_feat
,
anchor
,
stride
,
align_cls
in
zip
(
range
(
len
(
self
.
fpn_stride
)),
fpn_feats
,
anchors_split
,
self
.
fpn_stride
,
self
.
cls_align
):
for
i
,
fpn_feat
,
stride
,
align_cls
in
zip
(
range
(
len
(
self
.
fpn_stride
)),
fpn_feats
,
self
.
fpn_stride
,
self
.
cls_align
):
b
,
_
,
h
,
w
=
get_static_shape
(
fpn_feat
)
# task decomposition
conv_cls_feat
,
se_feat
=
self
.
conv_feat
(
fpn_feat
,
i
)
...
...
@@ -485,22 +482,35 @@ class PicoHeadV2(GFLHead):
else
:
cls_score
=
F
.
sigmoid
(
cls_logit
)
anchor_centers
=
bbox_center
(
anchor
).
unsqueeze
(
0
)
/
stride
anchor_centers
=
anchor_centers
.
reshape
([
1
,
h
,
w
,
2
])
pred_distances
=
self
.
distribution_project
(
reg_pred
.
transpose
([
0
,
2
,
3
,
1
])).
reshape
([
b
,
h
,
w
,
4
])
reg_bbox
=
batch_distance2bbox
(
anchor_centers
,
pred_distances
,
max_shapes
=
None
)
if
not
self
.
training
:
if
not
export_post_process
and
not
self
.
training
:
# Now only supports batch size = 1 in deploy
cls_score_list
.
append
(
cls_score
.
transpose
([
0
,
2
,
3
,
1
]).
reshape
(
[
b
,
-
1
,
self
.
cls_out_channels
]))
box_list
.
append
(
reg_bbox
.
reshape
([
b
,
-
1
,
4
])
*
stride
)
cls_score
.
reshape
([
1
,
self
.
cls_out_channels
,
-
1
]).
transpose
(
[
0
,
2
,
1
]))
box_list
.
append
(
reg_pred
.
reshape
([
1
,
(
self
.
reg_max
+
1
)
*
4
,
-
1
]).
transpose
(
[
0
,
2
,
1
]))
else
:
cls_score_list
.
append
(
cls_score
.
flatten
(
2
).
transpose
([
0
,
2
,
1
]))
reg_list
.
append
(
reg_pred
.
flatten
(
2
).
transpose
([
0
,
2
,
1
]))
box_list
.
append
(
reg_bbox
.
reshape
([
b
,
-
1
,
4
]))
cls_score_out
=
cls_score
.
transpose
([
0
,
2
,
3
,
1
])
bbox_pred
=
reg_pred
.
transpose
([
0
,
2
,
3
,
1
])
b
,
cell_h
,
cell_w
,
_
=
paddle
.
shape
(
cls_score_out
)
y
,
x
=
self
.
get_single_level_center_point
(
[
cell_h
,
cell_w
],
stride
,
cell_offset
=
self
.
cell_offset
)
center_points
=
paddle
.
stack
([
x
,
y
],
axis
=-
1
)
cls_score_out
=
cls_score_out
.
reshape
(
[
b
,
-
1
,
self
.
cls_out_channels
])
bbox_pred
=
self
.
distribution_project
(
bbox_pred
)
*
stride
bbox_pred
=
bbox_pred
.
reshape
([
b
,
cell_h
*
cell_w
,
4
])
bbox_pred
=
batch_distance2bbox
(
center_points
,
bbox_pred
,
max_shapes
=
None
)
if
not
self
.
training
:
cls_score_list
.
append
(
cls_score_out
)
box_list
.
append
(
bbox_pred
)
else
:
cls_score_list
.
append
(
cls_score
.
flatten
(
2
).
transpose
([
0
,
2
,
1
]))
reg_list
.
append
(
reg_pred
.
flatten
(
2
).
transpose
([
0
,
2
,
1
]))
box_list
.
append
(
bbox_pred
/
stride
)
if
not
self
.
training
:
return
cls_score_list
,
box_list
...
...
@@ -508,16 +518,19 @@ class PicoHeadV2(GFLHead):
cls_score_list
=
paddle
.
concat
(
cls_score_list
,
axis
=
1
)
box_list
=
paddle
.
concat
(
box_list
,
axis
=
1
)
reg_list
=
paddle
.
concat
(
reg_list
,
axis
=
1
)
return
cls_score_list
,
reg_list
,
box_list
,
anchors
,
num_anchors_list
,
stride_tensor_list
return
cls_score_list
,
reg_list
,
box_list
,
fpn_feats
def
get_loss
(
self
,
head_outs
,
gt_meta
):
pred_scores
,
pred_regs
,
pred_bboxes
,
anchors
,
num_anchors_list
,
stride_tensor_list
=
head_outs
pred_scores
,
pred_regs
,
pred_bboxes
,
fpn_feats
=
head_outs
gt_labels
=
gt_meta
[
'gt_class'
]
gt_bboxes
=
gt_meta
[
'gt_bbox'
]
gt_scores
=
gt_meta
[
'gt_score'
]
if
'gt_score'
in
gt_meta
else
None
num_imgs
=
gt_meta
[
'im_id'
].
shape
[
0
]
pad_gt_mask
=
gt_meta
[
'pad_gt_mask'
]
anchors
,
_
,
num_anchors_list
,
stride_tensor_list
=
generate_anchors_for_grid_cell
(
fpn_feats
,
self
.
fpn_stride
,
self
.
grid_cell_scale
,
self
.
cell_offset
)
centers
=
bbox_center
(
anchors
)
# label assignment
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录