Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
3134757f
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看板
未验证
提交
3134757f
编写于
3月 31, 2022
作者:
S
shangliang Xu
提交者:
GitHub
3月 31, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix one_hot error (#5536)
上级
4f05f2f9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
13 addition
and
4 deletion
+13
-4
ppdet/modeling/assigners/atss_assigner.py
ppdet/modeling/assigners/atss_assigner.py
+5
-1
ppdet/modeling/assigners/task_aligned_assigner.py
ppdet/modeling/assigners/task_aligned_assigner.py
+5
-1
ppdet/modeling/heads/ppyoloe_head.py
ppdet/modeling/heads/ppyoloe_head.py
+2
-1
ppdet/modeling/losses/detr_loss.py
ppdet/modeling/losses/detr_loss.py
+1
-1
未找到文件。
ppdet/modeling/assigners/atss_assigner.py
浏览文件 @
3134757f
...
@@ -199,7 +199,11 @@ class ATSSAssigner(nn.Layer):
...
@@ -199,7 +199,11 @@ class ATSSAssigner(nn.Layer):
gt_bboxes
.
reshape
([
-
1
,
4
]),
assigned_gt_index
.
flatten
(),
axis
=
0
)
gt_bboxes
.
reshape
([
-
1
,
4
]),
assigned_gt_index
.
flatten
(),
axis
=
0
)
assigned_bboxes
=
assigned_bboxes
.
reshape
([
batch_size
,
num_anchors
,
4
])
assigned_bboxes
=
assigned_bboxes
.
reshape
([
batch_size
,
num_anchors
,
4
])
assigned_scores
=
F
.
one_hot
(
assigned_labels
,
self
.
num_classes
)
assigned_scores
=
F
.
one_hot
(
assigned_labels
,
self
.
num_classes
+
1
)
ind
=
list
(
range
(
self
.
num_classes
+
1
))
ind
.
remove
(
bg_index
)
assigned_scores
=
paddle
.
index_select
(
assigned_scores
,
paddle
.
to_tensor
(
ind
),
axis
=-
1
)
if
pred_bboxes
is
not
None
:
if
pred_bboxes
is
not
None
:
# assigned iou
# assigned iou
ious
=
batch_iou_similarity
(
gt_bboxes
,
pred_bboxes
)
*
mask_positive
ious
=
batch_iou_similarity
(
gt_bboxes
,
pred_bboxes
)
*
mask_positive
...
...
ppdet/modeling/assigners/task_aligned_assigner.py
浏览文件 @
3134757f
...
@@ -143,7 +143,11 @@ class TaskAlignedAssigner(nn.Layer):
...
@@ -143,7 +143,11 @@ class TaskAlignedAssigner(nn.Layer):
gt_bboxes
.
reshape
([
-
1
,
4
]),
assigned_gt_index
.
flatten
(),
axis
=
0
)
gt_bboxes
.
reshape
([
-
1
,
4
]),
assigned_gt_index
.
flatten
(),
axis
=
0
)
assigned_bboxes
=
assigned_bboxes
.
reshape
([
batch_size
,
num_anchors
,
4
])
assigned_bboxes
=
assigned_bboxes
.
reshape
([
batch_size
,
num_anchors
,
4
])
assigned_scores
=
F
.
one_hot
(
assigned_labels
,
num_classes
)
assigned_scores
=
F
.
one_hot
(
assigned_labels
,
num_classes
+
1
)
ind
=
list
(
range
(
num_classes
+
1
))
ind
.
remove
(
bg_index
)
assigned_scores
=
paddle
.
index_select
(
assigned_scores
,
paddle
.
to_tensor
(
ind
),
axis
=-
1
)
# rescale alignment metrics
# rescale alignment metrics
alignment_metrics
*=
mask_positive
alignment_metrics
*=
mask_positive
max_metrics_per_instance
=
alignment_metrics
.
max
(
axis
=-
1
,
keepdim
=
True
)
max_metrics_per_instance
=
alignment_metrics
.
max
(
axis
=-
1
,
keepdim
=
True
)
...
...
ppdet/modeling/heads/ppyoloe_head.py
浏览文件 @
3134757f
...
@@ -331,7 +331,8 @@ class PPYOLOEHead(nn.Layer):
...
@@ -331,7 +331,8 @@ class PPYOLOEHead(nn.Layer):
assigned_bboxes
/=
stride_tensor
assigned_bboxes
/=
stride_tensor
# cls loss
# cls loss
if
self
.
use_varifocal_loss
:
if
self
.
use_varifocal_loss
:
one_hot_label
=
F
.
one_hot
(
assigned_labels
,
self
.
num_classes
)
one_hot_label
=
F
.
one_hot
(
assigned_labels
,
self
.
num_classes
+
1
)[...,
:
-
1
]
loss_cls
=
self
.
_varifocal_loss
(
pred_scores
,
assigned_scores
,
loss_cls
=
self
.
_varifocal_loss
(
pred_scores
,
assigned_scores
,
one_hot_label
)
one_hot_label
)
else
:
else
:
...
...
ppdet/modeling/losses/detr_loss.py
浏览文件 @
3134757f
...
@@ -80,7 +80,7 @@ class DETRLoss(nn.Layer):
...
@@ -80,7 +80,7 @@ class DETRLoss(nn.Layer):
target_label
=
target_label
.
reshape
([
bs
,
num_query_objects
])
target_label
=
target_label
.
reshape
([
bs
,
num_query_objects
])
if
self
.
use_focal_loss
:
if
self
.
use_focal_loss
:
target_label
=
F
.
one_hot
(
target_label
,
target_label
=
F
.
one_hot
(
target_label
,
self
.
num_classes
+
1
)[
:,
:
,
:
-
1
]
self
.
num_classes
+
1
)[
...
,
:
-
1
]
return
{
return
{
'loss_class'
:
self
.
loss_coeff
[
'class'
]
*
sigmoid_focal_loss
(
'loss_class'
:
self
.
loss_coeff
[
'class'
]
*
sigmoid_focal_loss
(
logits
,
target_label
,
num_gts
/
num_query_objects
)
logits
,
target_label
,
num_gts
/
num_query_objects
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录