Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
d48b3ff7
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看板
未验证
提交
d48b3ff7
编写于
1月 29, 2021
作者:
F
Feng Ni
提交者:
GitHub
1月 29, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fit for fcos (#2133)
上级
4b7917cd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
44 addition
and
24 deletion
+44
-24
dygraph/configs/fcos/_base_/fcos_r50_fpn.yml
dygraph/configs/fcos/_base_/fcos_r50_fpn.yml
+2
-4
dygraph/ppdet/modeling/architectures/fcos.py
dygraph/ppdet/modeling/architectures/fcos.py
+33
-16
dygraph/ppdet/modeling/necks/fpn.py
dygraph/ppdet/modeling/necks/fpn.py
+9
-4
未找到文件。
dygraph/configs/fcos/_base_/fcos_r50_fpn.yml
浏览文件 @
d48b3ff7
...
...
@@ -17,11 +17,9 @@ ResNet:
num_stages
:
4
FPN
:
in_channels
:
[
256
,
512
,
1024
,
2048
]
out_channel
:
256
min_level
:
1
max_level
:
5
spatial_scale
:
[
0.125
,
0.0625
,
0.03125
]
spatial_scales
:
[
0.125
,
0.0625
,
0.03125
]
extra_stage
:
2
has_extra_convs
:
true
use_c5
:
false
...
...
dygraph/ppdet/modeling/architectures/fcos.py
浏览文件 @
d48b3ff7
...
...
@@ -17,7 +17,7 @@ from __future__ import division
from
__future__
import
print_function
import
paddle
from
ppdet.core.workspace
import
register
from
ppdet.core.workspace
import
register
,
create
from
.meta_arch
import
BaseArch
__all__
=
[
'FCOS'
]
...
...
@@ -26,12 +26,7 @@ __all__ = ['FCOS']
@
register
class
FCOS
(
BaseArch
):
__category__
=
'architecture'
__inject__
=
[
'backbone'
,
'neck'
,
'fcos_head'
,
'fcos_post_process'
,
]
__inject__
=
[
'fcos_post_process'
]
def
__init__
(
self
,
backbone
,
...
...
@@ -44,16 +39,32 @@ class FCOS(BaseArch):
self
.
fcos_head
=
fcos_head
self
.
fcos_post_process
=
fcos_post_process
def
model_arch
(
self
,
):
body_feats
=
self
.
backbone
(
self
.
inputs
)
@
classmethod
def
from_config
(
cls
,
cfg
,
*
args
,
**
kwargs
):
backbone
=
create
(
cfg
[
'backbone'
])
kwargs
=
{
'input_shape'
:
backbone
.
out_shape
}
neck
=
create
(
cfg
[
'neck'
],
**
kwargs
)
fpn_feats
,
spatial_scale
=
self
.
neck
(
body_feats
)
kwargs
=
{
'input_shape'
:
neck
.
out_shape
}
fcos_head
=
create
(
cfg
[
'fcos_head'
],
**
kwargs
)
self
.
fcos_head_outs
=
self
.
fcos_head
(
fpn_feats
,
self
.
training
)
return
{
'backbone'
:
backbone
,
'neck'
:
neck
,
"fcos_head"
:
fcos_head
,
}
def
_forward
(
self
):
body_feats
=
self
.
backbone
(
self
.
inputs
)
fpn_feats
=
self
.
neck
(
body_feats
)
fcos_head_outs
=
self
.
fcos_head
(
fpn_feats
,
self
.
training
)
if
not
self
.
training
:
self
.
bboxes
=
self
.
fcos_post_process
(
self
.
fcos_head_outs
,
self
.
inputs
[
'scale_factor'
])
scale_factor
=
self
.
inputs
[
'scale_factor'
]
bboxes
=
self
.
fcos_post_process
(
fcos_head_outs
,
scale_factor
)
return
bboxes
else
:
return
fcos_head_outs
def
get_loss
(
self
,
):
loss
=
{}
...
...
@@ -70,7 +81,8 @@ class FCOS(BaseArch):
if
k_ctn
in
self
.
inputs
:
tag_centerness
.
append
(
self
.
inputs
[
k_ctn
])
loss_fcos
=
self
.
fcos_head
.
get_loss
(
self
.
fcos_head_outs
,
tag_labels
,
fcos_head_outs
=
self
.
_forward
()
loss_fcos
=
self
.
fcos_head
.
get_loss
(
fcos_head_outs
,
tag_labels
,
tag_bboxes
,
tag_centerness
)
loss
.
update
(
loss_fcos
)
total_loss
=
paddle
.
add_n
(
list
(
loss
.
values
()))
...
...
@@ -78,9 +90,14 @@ class FCOS(BaseArch):
return
loss
def
get_pred
(
self
):
bbox
,
bbox_num
=
self
.
bboxes
bboxes
,
bbox_num
=
self
.
_forward
()
label
=
bboxes
[:,
0
]
score
=
bboxes
[:,
1
]
bbox
=
bboxes
[:,
2
:]
output
=
{
'bbox'
:
bbox
,
'bbox_num'
:
bbox_num
,
'score'
:
score
,
'label'
:
label
,
'bbox_num'
:
bbox_num
}
return
output
dygraph/ppdet/modeling/necks/fpn.py
浏览文件 @
d48b3ff7
...
...
@@ -52,12 +52,16 @@ class FPN(Layer):
self
.
fpn_convs
=
[]
fan
=
out_channel
*
3
*
3
for
i
in
range
(
len
(
in_channels
)):
# stage index 0,1,2,3 stands for res2,res3,res4,res5 on ResNet Backbone
# 0 <= st_stage < ed_stage <= 3
st_stage
=
4
-
len
(
in_channels
)
ed_stage
=
st_stage
+
len
(
in_channels
)
-
1
for
i
in
range
(
st_stage
,
ed_stage
+
1
):
if
i
==
3
:
lateral_name
=
'fpn_inner_res5_sum'
else
:
lateral_name
=
'fpn_inner_res{}_sum_lateral'
.
format
(
i
+
2
)
in_c
=
in_channels
[
i
]
in_c
=
in_channels
[
i
-
st_stage
]
lateral
=
self
.
add_sublayer
(
lateral_name
,
Conv2D
(
...
...
@@ -82,8 +86,9 @@ class FPN(Layer):
# add extra conv levels for RetinaNet(use_c5)/FCOS(use_p5)
if
self
.
has_extra_convs
:
for
lvl
in
range
(
self
.
extra_stage
):
# P6 P7 ...
if
lvl
==
0
and
self
.
use_c5
:
for
i
in
range
(
self
.
extra_stage
):
lvl
=
ed_stage
+
1
+
i
if
i
==
0
and
self
.
use_c5
:
in_c
=
in_channels
[
-
1
]
else
:
in_c
=
out_channel
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录