Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
b352ef88
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看板
未验证
提交
b352ef88
编写于
3月 03, 2023
作者:
L
LokeZhou
提交者:
GitHub
3月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add picodet ppyoloe_crn_s_300e_coco static training (#7859)
上级
bb1ba033
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
68 addition
and
26 deletion
+68
-26
ppdet/engine/export_utils.py
ppdet/engine/export_utils.py
+40
-0
ppdet/modeling/assigners/atss_assigner.py
ppdet/modeling/assigners/atss_assigner.py
+4
-3
ppdet/modeling/assigners/task_aligned_assigner.py
ppdet/modeling/assigners/task_aligned_assigner.py
+1
-1
ppdet/modeling/assigners/task_aligned_assigner_cr.py
ppdet/modeling/assigners/task_aligned_assigner_cr.py
+1
-1
ppdet/modeling/heads/pico_head.py
ppdet/modeling/heads/pico_head.py
+2
-2
ppdet/modeling/heads/ppyoloe_contrast_head.py
ppdet/modeling/heads/ppyoloe_contrast_head.py
+3
-3
ppdet/modeling/heads/ppyoloe_head.py
ppdet/modeling/heads/ppyoloe_head.py
+14
-15
test_tipc/configs/picodet/picodet_s_320_coco_lcnet_train_infer_python.txt
...s/picodet/picodet_s_320_coco_lcnet_train_infer_python.txt
+3
-1
未找到文件。
ppdet/engine/export_utils.py
浏览文件 @
b352ef88
...
...
@@ -142,6 +142,46 @@ TO_STATIC_SPEC = {
'centerness4'
:
paddle
.
static
.
InputSpec
(
name
=
'centerness4'
,
shape
=
[
-
1
,
10
,
10
,
1
],
dtype
=
'float32'
),
}],
'picodet_s_320_coco_lcnet'
:
[{
'im_id'
:
paddle
.
static
.
InputSpec
(
name
=
'im_id'
,
shape
=
[
-
1
,
1
],
dtype
=
'float32'
),
'is_crowd'
:
paddle
.
static
.
InputSpec
(
name
=
'is_crowd'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'float32'
),
'gt_class'
:
paddle
.
static
.
InputSpec
(
name
=
'gt_class'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'int32'
),
'gt_bbox'
:
paddle
.
static
.
InputSpec
(
name
=
'gt_bbox'
,
shape
=
[
-
1
,
-
1
,
4
],
dtype
=
'float32'
),
'curr_iter'
:
paddle
.
static
.
InputSpec
(
name
=
'curr_iter'
,
shape
=
[
-
1
],
dtype
=
'float32'
),
'image'
:
paddle
.
static
.
InputSpec
(
name
=
'image'
,
shape
=
[
-
1
,
3
,
-
1
,
-
1
],
dtype
=
'float32'
),
'im_shape'
:
paddle
.
static
.
InputSpec
(
name
=
'im_shape'
,
shape
=
[
-
1
,
2
],
dtype
=
'float32'
),
'scale_factor'
:
paddle
.
static
.
InputSpec
(
name
=
'scale_factor'
,
shape
=
[
-
1
,
2
],
dtype
=
'float32'
),
'pad_gt_mask'
:
paddle
.
static
.
InputSpec
(
name
=
'pad_gt_mask'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'float32'
),
}],
'ppyoloe_crn_s_300e_coco'
:
[{
'im_id'
:
paddle
.
static
.
InputSpec
(
name
=
'im_id'
,
shape
=
[
-
1
,
1
],
dtype
=
'float32'
),
'is_crowd'
:
paddle
.
static
.
InputSpec
(
name
=
'is_crowd'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'float32'
),
'gt_class'
:
paddle
.
static
.
InputSpec
(
name
=
'gt_class'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'int32'
),
'gt_bbox'
:
paddle
.
static
.
InputSpec
(
name
=
'gt_bbox'
,
shape
=
[
-
1
,
-
1
,
4
],
dtype
=
'float32'
),
'curr_iter'
:
paddle
.
static
.
InputSpec
(
name
=
'curr_iter'
,
shape
=
[
-
1
],
dtype
=
'float32'
),
'image'
:
paddle
.
static
.
InputSpec
(
name
=
'image'
,
shape
=
[
-
1
,
3
,
-
1
,
-
1
],
dtype
=
'float32'
),
'im_shape'
:
paddle
.
static
.
InputSpec
(
name
=
'im_shape'
,
shape
=
[
-
1
,
2
],
dtype
=
'float32'
),
'scale_factor'
:
paddle
.
static
.
InputSpec
(
name
=
'scale_factor'
,
shape
=
[
-
1
,
2
],
dtype
=
'float32'
),
'pad_gt_mask'
:
paddle
.
static
.
InputSpec
(
name
=
'pad_gt_mask'
,
shape
=
[
-
1
,
-
1
,
1
],
dtype
=
'float32'
),
}],
}
...
...
ppdet/modeling/assigners/atss_assigner.py
浏览文件 @
b352ef88
...
...
@@ -169,8 +169,9 @@ class ATSSAssigner(nn.Layer):
# the one with the highest iou will be selected.
mask_positive_sum
=
mask_positive
.
sum
(
axis
=-
2
)
if
mask_positive_sum
.
max
()
>
1
:
mask_multiple_gts
=
(
mask_positive_sum
.
unsqueeze
(
1
)
>
1
).
tile
(
[
1
,
num_max_boxes
,
1
])
mask_multiple_gts
=
(
mask_positive_sum
.
unsqueeze
(
1
)
>
1
).
astype
(
'int32'
).
tile
(
[
1
,
num_max_boxes
,
1
]).
astype
(
'bool'
)
if
self
.
sm_use
:
is_max_iou
=
compute_max_iou_anchor
(
ious
*
mask_positive
)
else
:
...
...
@@ -221,4 +222,4 @@ class ATSSAssigner(nn.Layer):
paddle
.
zeros_like
(
gather_scores
))
assigned_scores
*=
gather_scores
.
unsqueeze
(
-
1
)
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
ppdet/modeling/assigners/task_aligned_assigner.py
浏览文件 @
b352ef88
...
...
@@ -190,4 +190,4 @@ class TaskAlignedAssigner(nn.Layer):
alignment_metrics
=
alignment_metrics
.
max
(
-
2
).
unsqueeze
(
-
1
)
assigned_scores
=
assigned_scores
*
alignment_metrics
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
ppdet/modeling/assigners/task_aligned_assigner_cr.py
浏览文件 @
b352ef88
...
...
@@ -178,4 +178,4 @@ class TaskAlignedAssigner_CR(nn.Layer):
alignment_metrics
=
alignment_metrics
.
max
(
-
2
).
unsqueeze
(
-
1
)
assigned_scores
=
assigned_scores
*
alignment_metrics
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
return
assigned_labels
,
assigned_bboxes
,
assigned_scores
ppdet/modeling/heads/pico_head.py
浏览文件 @
b352ef88
...
...
@@ -651,7 +651,7 @@ class PicoHeadV2(GFLHead):
# label assignment
if
gt_meta
[
'epoch_id'
]
<
self
.
static_assigner_epoch
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
_
=
self
.
static_assigner
(
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
self
.
static_assigner
(
anchors
,
num_anchors_list
,
gt_labels
,
...
...
@@ -662,7 +662,7 @@ class PicoHeadV2(GFLHead):
pred_bboxes
=
pred_bboxes
.
detach
()
*
stride_tensor_list
)
else
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
_
=
self
.
assigner
(
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
self
.
assigner
(
pred_scores
.
detach
(),
pred_bboxes
.
detach
()
*
stride_tensor_list
,
centers
,
...
...
ppdet/modeling/heads/ppyoloe_contrast_head.py
浏览文件 @
b352ef88
...
...
@@ -121,7 +121,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
pad_gt_mask
=
gt_meta
[
'pad_gt_mask'
]
# label assignment
if
gt_meta
[
'epoch_id'
]
<
self
.
static_assigner_epoch
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
_
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
static_assigner
(
anchors
,
num_anchors_list
,
...
...
@@ -133,7 +133,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
alpha_l
=
0.25
else
:
if
self
.
sm_use
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
_
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
assigner
(
pred_scores
.
detach
(),
pred_bboxes
.
detach
()
*
stride_tensor
,
...
...
@@ -144,7 +144,7 @@ class PPYOLOEContrastHead(PPYOLOEHead):
pad_gt_mask
,
bg_index
=
self
.
num_classes
)
else
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
_
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
assigner
(
pred_scores
.
detach
(),
pred_bboxes
.
detach
()
*
stride_tensor
,
...
...
ppdet/modeling/heads/ppyoloe_head.py
浏览文件 @
b352ef88
...
...
@@ -337,7 +337,8 @@ class PPYOLOEHead(nn.Layer):
# pos/neg loss
if
num_pos
>
0
:
# l1 + iou
bbox_mask
=
mask_positive
.
unsqueeze
(
-
1
).
tile
([
1
,
1
,
4
])
bbox_mask
=
mask_positive
.
astype
(
'int32'
).
unsqueeze
(
-
1
).
tile
(
[
1
,
1
,
4
]).
astype
(
'bool'
)
pred_bboxes_pos
=
paddle
.
masked_select
(
pred_bboxes
,
bbox_mask
).
reshape
([
-
1
,
4
])
assigned_bboxes_pos
=
paddle
.
masked_select
(
...
...
@@ -351,8 +352,8 @@ class PPYOLOEHead(nn.Layer):
assigned_bboxes_pos
)
*
bbox_weight
loss_iou
=
loss_iou
.
sum
()
/
assigned_scores_sum
dist_mask
=
mask_positive
.
unsqueeze
(
-
1
).
tile
(
[
1
,
1
,
self
.
reg_channels
*
4
])
dist_mask
=
mask_positive
.
unsqueeze
(
-
1
).
astype
(
'int32'
).
tile
(
[
1
,
1
,
self
.
reg_channels
*
4
])
.
astype
(
'bool'
)
pred_dist_pos
=
paddle
.
masked_select
(
pred_dist
,
dist_mask
).
reshape
([
-
1
,
4
,
self
.
reg_channels
])
assigned_ltrb
=
self
.
_bbox2distance
(
anchor_points
,
assigned_bboxes
)
...
...
@@ -387,7 +388,7 @@ class PPYOLOEHead(nn.Layer):
pad_gt_mask
=
gt_meta
[
'pad_gt_mask'
]
# label assignment
if
gt_meta
[
'epoch_id'
]
<
self
.
static_assigner_epoch
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
static_assigner
(
anchors
,
num_anchors_list
,
...
...
@@ -400,7 +401,7 @@ class PPYOLOEHead(nn.Layer):
else
:
if
self
.
sm_use
:
# only used in smalldet of PPYOLOE-SOD model
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
assigner
(
pred_scores
.
detach
(),
pred_bboxes
.
detach
()
*
stride_tensor
,
...
...
@@ -413,7 +414,7 @@ class PPYOLOEHead(nn.Layer):
else
:
if
aux_pred
is
None
:
if
not
hasattr
(
self
,
"assigned_labels"
):
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
assigner
(
pred_scores
.
detach
(),
pred_bboxes
.
detach
()
*
stride_tensor
,
...
...
@@ -427,15 +428,15 @@ class PPYOLOEHead(nn.Layer):
self
.
assigned_labels
=
assigned_labels
self
.
assigned_bboxes
=
assigned_bboxes
self
.
assigned_scores
=
assigned_scores
self
.
mask_positive
=
mask_positive
else
:
# only used in distill
assigned_labels
=
self
.
assigned_labels
assigned_bboxes
=
self
.
assigned_bboxes
assigned_scores
=
self
.
assigned_scores
mask_positive
=
self
.
mask_positive
else
:
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
=
\
assigned_labels
,
assigned_bboxes
,
assigned_scores
=
\
self
.
assigner
(
pred_scores_aux
.
detach
(),
pred_bboxes_aux
.
detach
()
*
stride_tensor
,
...
...
@@ -451,14 +452,12 @@ class PPYOLOEHead(nn.Layer):
assign_out_dict
=
self
.
get_loss_from_assign
(
pred_scores
,
pred_distri
,
pred_bboxes
,
anchor_points_s
,
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
,
alpha_l
)
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
alpha_l
)
if
aux_pred
is
not
None
:
assign_out_dict_aux
=
self
.
get_loss_from_assign
(
aux_pred
[
0
],
aux_pred
[
1
],
pred_bboxes_aux
,
anchor_points_s
,
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
,
alpha_l
)
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
alpha_l
)
loss
=
{}
for
key
in
assign_out_dict
.
keys
():
loss
[
key
]
=
assign_out_dict
[
key
]
+
assign_out_dict_aux
[
key
]
...
...
@@ -469,7 +468,7 @@ class PPYOLOEHead(nn.Layer):
def
get_loss_from_assign
(
self
,
pred_scores
,
pred_distri
,
pred_bboxes
,
anchor_points_s
,
assigned_labels
,
assigned_bboxes
,
assigned_scores
,
mask_positive
,
alpha_l
):
assigned_scores
,
alpha_l
):
# cls loss
if
self
.
use_varifocal_loss
:
one_hot_label
=
F
.
one_hot
(
assigned_labels
,
...
...
@@ -490,7 +489,7 @@ class PPYOLOEHead(nn.Layer):
self
.
distill_pairs
[
'pred_cls_scores'
]
=
pred_scores
self
.
distill_pairs
[
'pos_num'
]
=
assigned_scores_sum
self
.
distill_pairs
[
'assigned_scores'
]
=
assigned_scores
self
.
distill_pairs
[
'mask_positive'
]
=
mask_positive
one_hot_label
=
F
.
one_hot
(
assigned_labels
,
self
.
num_classes
+
1
)[...,
:
-
1
]
self
.
distill_pairs
[
'target_labels'
]
=
one_hot_label
...
...
test_tipc/configs/picodet/picodet_s_320_coco_lcnet_train_infer_python.txt
浏览文件 @
b352ef88
...
...
@@ -58,3 +58,5 @@ repeat:25
flags:null
===========================infer_benchmark_params===========================
numpy_infer_input:3x320x320_2.npy
===========================to_static_train_benchmark_params===========================
to_static_train:--to_static
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录