Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleX
提交
eca9870e
P
PaddleX
项目概览
PaddlePaddle
/
PaddleX
通知
138
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
43
列表
看板
标记
里程碑
合并请求
5
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleX
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
43
Issue
43
列表
看板
标记
里程碑
合并请求
5
合并请求
5
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
eca9870e
编写于
6月 03, 2020
作者:
S
sunyanfang01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
for review
上级
2279d7c4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
65 addition
and
27 deletion
+65
-27
paddlex/cv/models/faster_rcnn.py
paddlex/cv/models/faster_rcnn.py
+7
-0
paddlex/cv/nets/detection/bbox_head.py
paddlex/cv/nets/detection/bbox_head.py
+4
-18
paddlex/cv/nets/detection/loss/diou_loss.py
paddlex/cv/nets/detection/loss/diou_loss.py
+9
-9
paddlex/cv/nets/detection/loss/smoothl1_loss.py
paddlex/cv/nets/detection/loss/smoothl1_loss.py
+45
-0
未找到文件。
paddlex/cv/models/faster_rcnn.py
浏览文件 @
eca9870e
...
@@ -53,6 +53,11 @@ class FasterRCNN(BaseAPI):
...
@@ -53,6 +53,11 @@ class FasterRCNN(BaseAPI):
]
]
assert
backbone
in
backbones
,
"backbone should be one of {}"
.
format
(
assert
backbone
in
backbones
,
"backbone should be one of {}"
.
format
(
backbones
)
backbones
)
bbox_loss_types
=
[
'SmoothL1Loss'
,
'CiouLoss'
,
'DiouLoss'
,
'GiouLoss'
]
assert
backbone
in
backbones
,
"bbox_loss_type should be one of {}"
.
format
(
bbox_loss_types
)
self
.
backbone
=
backbone
self
.
backbone
=
backbone
self
.
num_classes
=
num_classes
self
.
num_classes
=
num_classes
self
.
with_fpn
=
with_fpn
self
.
with_fpn
=
with_fpn
...
@@ -84,6 +89,8 @@ class FasterRCNN(BaseAPI):
...
@@ -84,6 +89,8 @@ class FasterRCNN(BaseAPI):
layers
=
101
layers
=
101
variant
=
'd'
variant
=
'd'
norm_type
=
'affine_channel'
norm_type
=
'affine_channel'
if
self
.
bbox_loss_type
!=
'SmoothL1Loss'
:
norm_type
=
'bn'
elif
backbone_name
==
'HRNet_W18'
:
elif
backbone_name
==
'HRNet_W18'
:
backbone
=
paddlex
.
cv
.
nets
.
hrnet
.
HRNet
(
backbone
=
paddlex
.
cv
.
nets
.
hrnet
.
HRNet
(
width
=
18
,
freeze_norm
=
True
,
norm_decay
=
0.
,
freeze_at
=
0
)
width
=
18
,
freeze_norm
=
True
,
norm_decay
=
0.
,
freeze_at
=
0
)
...
...
paddlex/cv/nets/detection/bbox_head.py
浏览文件 @
eca9870e
...
@@ -188,39 +188,25 @@ class BBoxHead(object):
...
@@ -188,39 +188,25 @@ class BBoxHead(object):
is_cls_agnostic
=
False
,
is_cls_agnostic
=
False
,
num_classes
=
self
.
num_classes
,
num_classes
=
self
.
num_classes
,
use_complete_iou_loss
=
True
)
use_complete_iou_loss
=
True
)
loss_bbox
=
loss_obj
(
x
=
bbox_pred
,
y
=
bbox_targets
,
inside_weight
=
bbox_inside_weights
,
outside_weight
=
bbox_outside_weights
)
elif
self
.
bbox_loss_type
==
'DiouLoss'
:
elif
self
.
bbox_loss_type
==
'DiouLoss'
:
from
.loss.diou_loss
import
DiouLoss
from
.loss.diou_loss
import
DiouLoss
loss_obj
=
DiouLoss
(
loss_weight
=
12.
,
loss_obj
=
DiouLoss
(
loss_weight
=
12.
,
is_cls_agnostic
=
False
,
is_cls_agnostic
=
False
,
num_classes
=
self
.
num_classes
,
num_classes
=
self
.
num_classes
,
use_complete_iou_loss
=
False
)
use_complete_iou_loss
=
False
)
loss_bbox
=
loss_obj
(
x
=
bbox_pred
,
y
=
bbox_targets
,
inside_weight
=
bbox_inside_weights
,
outside_weight
=
bbox_outside_weights
)
elif
self
.
bbox_loss_type
==
'GiouLoss'
:
elif
self
.
bbox_loss_type
==
'GiouLoss'
:
from
.loss.giou_loss
import
GiouLoss
from
.loss.giou_loss
import
GiouLoss
loss_obj
=
GiouLoss
(
loss_weight
=
10.
,
loss_obj
=
GiouLoss
(
loss_weight
=
10.
,
is_cls_agnostic
=
False
,
is_cls_agnostic
=
False
,
num_classes
=
self
.
num_classes
)
num_classes
=
self
.
num_classes
)
else
:
from
.loss.smoothl1_loss
import
SmoothL1Loss
loss_obj
=
SmoothL1Loss
(
self
.
sigma
)
loss_bbox
=
loss_obj
(
loss_bbox
=
loss_obj
(
x
=
bbox_pred
,
x
=
bbox_pred
,
y
=
bbox_targets
,
y
=
bbox_targets
,
inside_weight
=
bbox_inside_weights
,
inside_weight
=
bbox_inside_weights
,
outside_weight
=
bbox_outside_weights
)
outside_weight
=
bbox_outside_weights
)
else
:
loss_bbox
=
fluid
.
layers
.
smooth_l1
(
x
=
bbox_pred
,
y
=
bbox_targets
,
inside_weight
=
bbox_inside_weights
,
outside_weight
=
bbox_outside_weights
,
sigma
=
self
.
sigma
)
loss_bbox
=
fluid
.
layers
.
reduce_mean
(
loss_bbox
)
loss_bbox
=
fluid
.
layers
.
reduce_mean
(
loss_bbox
)
return
{
'loss_cls'
:
loss_cls
,
'loss_bbox'
:
loss_bbox
}
return
{
'loss_cls'
:
loss_cls
,
'loss_bbox'
:
loss_bbox
}
...
...
paddlex/cv/nets/detection/loss/diou_loss.py
浏览文件 @
eca9870e
#copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
copyright (c) 2020 PaddlePaddle Authors. All Rights Reserve.
#
#
#Licensed under the Apache License, Version 2.0 (the "License");
#
Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#
you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
#
#Unless required by applicable law or agreed to in writing, software
#
Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#
distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#
See the License for the specific language governing permissions and
#limitations under the License.
#
limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
division
...
...
paddlex/cv/nets/detection/loss/smoothl1_loss.py
0 → 100644
浏览文件 @
eca9870e
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
numpy
as
np
from
paddle
import
fluid
class
SmoothL1Loss
(
object
):
'''
SmoothL1 Loss
Args:
sigma (float): Hyper parameter of smooth L1 loss layer.
'''
def
__init__
(
self
,
sigma
):
self
.
sigma
=
sigma
def
__call__
(
self
,
x
,
y
,
inside_weight
=
None
,
outside_weight
=
None
):
loss_bbox
=
fluid
.
layers
.
smooth_l1
(
x
=
x
,
y
=
y
,
inside_weight
=
inside_weight
,
outside_weight
=
outside_weight
,
sigma
=
self
.
sigma
)
return
loss_bbox
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录