Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f8b2d8a4
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f8b2d8a4
编写于
8月 08, 2019
作者:
Y
Yuan Gao
提交者:
wangguanzhong
8月 08, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
standard SENet and add a warning in coco loader (#3047)
* standard SENet and add a warning in coco loader
上级
f8b4dfed
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
14 deletion
+52
-14
PaddleCV/PaddleDetection/ppdet/data/source/coco_loader.py
PaddleCV/PaddleDetection/ppdet/data/source/coco_loader.py
+4
-0
PaddleCV/PaddleDetection/ppdet/modeling/backbones/resnet.py
PaddleCV/PaddleDetection/ppdet/modeling/backbones/resnet.py
+45
-13
PaddleCV/PaddleDetection/ppdet/modeling/backbones/senet.py
PaddleCV/PaddleDetection/ppdet/modeling/backbones/senet.py
+3
-1
未找到文件。
PaddleCV/PaddleDetection/ppdet/data/source/coco_loader.py
浏览文件 @
f8b2d8a4
...
@@ -83,6 +83,10 @@ def load(anno_path, sample_num=-1, with_background=True):
...
@@ -83,6 +83,10 @@ def load(anno_path, sample_num=-1, with_background=True):
if
inst
[
'area'
]
>
0
and
x2
>=
x1
and
y2
>=
y1
:
if
inst
[
'area'
]
>
0
and
x2
>=
x1
and
y2
>=
y1
:
inst
[
'clean_bbox'
]
=
[
x1
,
y1
,
x2
,
y2
]
inst
[
'clean_bbox'
]
=
[
x1
,
y1
,
x2
,
y2
]
bboxes
.
append
(
inst
)
bboxes
.
append
(
inst
)
else
:
logger
.
warn
(
'Found an invalid bbox in annotations: im_id: {}, area: {} x: {}, y: {}, h: {}, w: {}.'
.
format
(
img_id
,
float
(
inst
[
'area'
]),
x
,
y
,
box_w
,
box_h
))
num_bbox
=
len
(
bboxes
)
num_bbox
=
len
(
bboxes
)
gt_bbox
=
np
.
zeros
((
num_bbox
,
4
),
dtype
=
np
.
float32
)
gt_bbox
=
np
.
zeros
((
num_bbox
,
4
),
dtype
=
np
.
float32
)
...
...
PaddleCV/PaddleDetection/ppdet/modeling/backbones/resnet.py
浏览文件 @
f8b2d8a4
...
@@ -89,9 +89,16 @@ class ResNet(object):
...
@@ -89,9 +89,16 @@ class ResNet(object):
self
.
_c1_out_chan_num
=
64
self
.
_c1_out_chan_num
=
64
self
.
na
=
NameAdapter
(
self
)
self
.
na
=
NameAdapter
(
self
)
def
_conv_offset
(
self
,
input
,
filter_size
,
stride
,
padding
,
act
=
None
,
name
=
None
):
def
_conv_offset
(
self
,
input
,
filter_size
,
stride
,
padding
,
act
=
None
,
name
=
None
):
out_channel
=
filter_size
*
filter_size
*
3
out_channel
=
filter_size
*
filter_size
*
3
out
=
fluid
.
layers
.
conv2d
(
input
,
out
=
fluid
.
layers
.
conv2d
(
input
,
num_filters
=
out_channel
,
num_filters
=
out_channel
,
filter_size
=
filter_size
,
filter_size
=
filter_size
,
stride
=
stride
,
stride
=
stride
,
...
@@ -132,8 +139,8 @@ class ResNet(object):
...
@@ -132,8 +139,8 @@ class ResNet(object):
padding
=
(
filter_size
-
1
)
//
2
,
padding
=
(
filter_size
-
1
)
//
2
,
act
=
None
,
act
=
None
,
name
=
name
+
"_conv_offset"
)
name
=
name
+
"_conv_offset"
)
offset_channel
=
filter_size
**
2
*
2
offset_channel
=
filter_size
**
2
*
2
mask_channel
=
filter_size
**
2
mask_channel
=
filter_size
**
2
offset
,
mask
=
fluid
.
layers
.
split
(
offset
,
mask
=
fluid
.
layers
.
split
(
input
=
offset_mask
,
input
=
offset_mask
,
num_or_sections
=
[
offset_channel
,
mask_channel
],
num_or_sections
=
[
offset_channel
,
mask_channel
],
...
@@ -203,7 +210,13 @@ class ResNet(object):
...
@@ -203,7 +210,13 @@ class ResNet(object):
ch_in
=
input
.
shape
[
1
]
ch_in
=
input
.
shape
[
1
]
# the naming rule is same as pretrained weight
# the naming rule is same as pretrained weight
name
=
self
.
na
.
fix_shortcut_name
(
name
)
name
=
self
.
na
.
fix_shortcut_name
(
name
)
std_senet
=
getattr
(
self
,
'std_senet'
,
False
)
if
ch_in
!=
ch_out
or
stride
!=
1
or
(
self
.
depth
<
50
and
is_first
):
if
ch_in
!=
ch_out
or
stride
!=
1
or
(
self
.
depth
<
50
and
is_first
):
if
std_senet
:
if
is_first
:
return
self
.
_conv_norm
(
input
,
ch_out
,
1
,
stride
,
name
=
name
)
else
:
return
self
.
_conv_norm
(
input
,
ch_out
,
3
,
stride
,
name
=
name
)
if
max_pooling_in_short_cut
and
not
is_first
:
if
max_pooling_in_short_cut
and
not
is_first
:
input
=
fluid
.
layers
.
pool2d
(
input
=
fluid
.
layers
.
pool2d
(
input
=
input
,
input
=
input
,
...
@@ -217,7 +230,13 @@ class ResNet(object):
...
@@ -217,7 +230,13 @@ class ResNet(object):
else
:
else
:
return
input
return
input
def
bottleneck
(
self
,
input
,
num_filters
,
stride
,
is_first
,
name
,
dcn_v2
=
False
):
def
bottleneck
(
self
,
input
,
num_filters
,
stride
,
is_first
,
name
,
dcn_v2
=
False
):
if
self
.
variant
==
'a'
:
if
self
.
variant
==
'a'
:
stride1
,
stride2
=
stride
,
1
stride1
,
stride2
=
stride
,
1
else
:
else
:
...
@@ -236,9 +255,17 @@ class ResNet(object):
...
@@ -236,9 +255,17 @@ class ResNet(object):
conv_name1
,
conv_name2
,
conv_name3
,
\
conv_name1
,
conv_name2
,
conv_name3
,
\
shortcut_name
=
self
.
na
.
fix_bottleneck_name
(
name
)
shortcut_name
=
self
.
na
.
fix_bottleneck_name
(
name
)
conv_def
=
[[
num_filters
,
1
,
stride1
,
'relu'
,
1
,
conv_name1
],
std_senet
=
getattr
(
self
,
'std_senet'
,
False
)
[
num_filters
,
3
,
stride2
,
'relu'
,
groups
,
conv_name2
],
if
std_senet
:
[
num_filters
*
expand
,
1
,
1
,
None
,
1
,
conv_name3
]]
conv_def
=
[
[
int
(
num_filters
/
2
),
1
,
stride1
,
'relu'
,
1
,
conv_name1
],
[
num_filters
,
3
,
stride2
,
'relu'
,
groups
,
conv_name2
],
[
num_filters
*
expand
,
1
,
1
,
None
,
1
,
conv_name3
]
]
else
:
conv_def
=
[[
num_filters
,
1
,
stride1
,
'relu'
,
1
,
conv_name1
],
[
num_filters
,
3
,
stride2
,
'relu'
,
groups
,
conv_name2
],
[
num_filters
*
expand
,
1
,
1
,
None
,
1
,
conv_name3
]]
residual
=
input
residual
=
input
for
i
,
(
c
,
k
,
s
,
act
,
g
,
_name
)
in
enumerate
(
conv_def
):
for
i
,
(
c
,
k
,
s
,
act
,
g
,
_name
)
in
enumerate
(
conv_def
):
...
@@ -250,7 +277,7 @@ class ResNet(object):
...
@@ -250,7 +277,7 @@ class ResNet(object):
act
=
act
,
act
=
act
,
groups
=
g
,
groups
=
g
,
name
=
_name
,
name
=
_name
,
dcn_v2
=
(
i
==
1
and
dcn_v2
))
dcn_v2
=
(
i
==
1
and
dcn_v2
))
short
=
self
.
_shortcut
(
short
=
self
.
_shortcut
(
input
,
input
,
num_filters
*
expand
,
num_filters
*
expand
,
...
@@ -264,7 +291,13 @@ class ResNet(object):
...
@@ -264,7 +291,13 @@ class ResNet(object):
return
fluid
.
layers
.
elementwise_add
(
return
fluid
.
layers
.
elementwise_add
(
x
=
short
,
y
=
residual
,
act
=
'relu'
,
name
=
name
+
".add.output.5"
)
x
=
short
,
y
=
residual
,
act
=
'relu'
,
name
=
name
+
".add.output.5"
)
def
basicblock
(
self
,
input
,
num_filters
,
stride
,
is_first
,
name
,
dcn_v2
=
False
):
def
basicblock
(
self
,
input
,
num_filters
,
stride
,
is_first
,
name
,
dcn_v2
=
False
):
assert
dcn_v2
is
False
,
"Not implemented yet."
assert
dcn_v2
is
False
,
"Not implemented yet."
conv0
=
self
.
_conv_norm
(
conv0
=
self
.
_conv_norm
(
input
=
input
,
input
=
input
,
...
@@ -385,7 +418,6 @@ class ResNetC5(ResNet):
...
@@ -385,7 +418,6 @@ class ResNetC5(ResNet):
norm_decay
=
0.
,
norm_decay
=
0.
,
variant
=
'b'
,
variant
=
'b'
,
feature_maps
=
[
5
]):
feature_maps
=
[
5
]):
super
(
ResNetC5
,
self
).
__init__
(
super
(
ResNetC5
,
self
).
__init__
(
depth
,
freeze_at
,
norm_type
,
freeze_norm
,
depth
,
freeze_at
,
norm_type
,
freeze_norm
,
norm_decay
,
norm_decay
,
variant
,
feature_maps
)
variant
,
feature_maps
)
self
.
severed_head
=
True
self
.
severed_head
=
True
PaddleCV/PaddleDetection/ppdet/modeling/backbones/senet.py
浏览文件 @
f8b2d8a4
...
@@ -55,7 +55,8 @@ class SENet(ResNeXt):
...
@@ -55,7 +55,8 @@ class SENet(ResNeXt):
norm_decay
=
0.
,
norm_decay
=
0.
,
variant
=
'd'
,
variant
=
'd'
,
feature_maps
=
[
2
,
3
,
4
,
5
],
feature_maps
=
[
2
,
3
,
4
,
5
],
dcn_v2_stages
=
[]):
dcn_v2_stages
=
[],
std_senet
=
False
):
super
(
SENet
,
self
).
__init__
(
depth
,
groups
,
group_width
,
freeze_at
,
super
(
SENet
,
self
).
__init__
(
depth
,
groups
,
group_width
,
freeze_at
,
norm_type
,
freeze_norm
,
norm_decay
,
variant
,
norm_type
,
freeze_norm
,
norm_decay
,
variant
,
feature_maps
)
feature_maps
)
...
@@ -64,6 +65,7 @@ class SENet(ResNeXt):
...
@@ -64,6 +65,7 @@ class SENet(ResNeXt):
else
:
else
:
self
.
stage_filters
=
[
256
,
512
,
1024
,
2048
]
self
.
stage_filters
=
[
256
,
512
,
1024
,
2048
]
self
.
reduction_ratio
=
16
self
.
reduction_ratio
=
16
self
.
std_senet
=
std_senet
self
.
_c1_out_chan_num
=
128
self
.
_c1_out_chan_num
=
128
self
.
_model_type
=
'SEResNeXt'
self
.
_model_type
=
'SEResNeXt'
self
.
dcn_v2_stages
=
dcn_v2_stages
self
.
dcn_v2_stages
=
dcn_v2_stages
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录