Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleClas
提交
07e1e5dc
P
PaddleClas
项目概览
PaddlePaddle
/
PaddleClas
大约 1 年 前同步成功
通知
115
Star
4999
Fork
1114
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
6
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleClas
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
6
合并请求
6
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
07e1e5dc
编写于
5月 14, 2020
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cspnet
上级
9123f5da
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
68 addition
and
74 deletion
+68
-74
ppcls/modeling/architectures/__init__.py
ppcls/modeling/architectures/__init__.py
+1
-1
ppcls/modeling/architectures/csp_resnet.py
ppcls/modeling/architectures/csp_resnet.py
+67
-73
未找到文件。
ppcls/modeling/architectures/__init__.py
浏览文件 @
07e1e5dc
...
@@ -46,4 +46,4 @@ from .resnet_acnet import ResNet18_ACNet, ResNet34_ACNet, ResNet50_ACNet, ResNet
...
@@ -46,4 +46,4 @@ from .resnet_acnet import ResNet18_ACNet, ResNet34_ACNet, ResNet50_ACNet, ResNet
# distillation model
# distillation model
from
.distillation_models
import
ResNet50_vd_distill_MobileNetV3_large_x1_0
,
ResNeXt101_32x16d_wsl_distill_ResNet50_vd
from
.distillation_models
import
ResNet50_vd_distill_MobileNetV3_large_x1_0
,
ResNeXt101_32x16d_wsl_distill_ResNet50_vd
from
.csp_resnet
import
CSPResNet50
from
.csp_resnet
import
*
ppcls/modeling/architectures/csp_resnet.py
浏览文件 @
07e1e5dc
...
@@ -18,11 +18,10 @@ from __future__ import print_function
...
@@ -18,11 +18,10 @@ from __future__ import print_function
import
math
import
math
import
paddle
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
from
paddle.fluid.param_attr
import
ParamAttr
from
paddle.fluid.param_attr
import
ParamAttr
__all__
=
[
"CSPResNet50"
,
]
__all__
=
[
"CSPResNet50"
,
"CSPResNet101"
]
class
CSPResNet
():
class
CSPResNet
():
...
@@ -31,19 +30,16 @@ class CSPResNet():
...
@@ -31,19 +30,16 @@ class CSPResNet():
def
net
(
self
,
input
,
class_dim
=
1000
,
data_format
=
"NCHW"
):
def
net
(
self
,
input
,
class_dim
=
1000
,
data_format
=
"NCHW"
):
layers
=
self
.
layers
layers
=
self
.
layers
supported_layers
=
[
18
,
34
,
50
,
101
,
152
]
supported_layers
=
[
50
,
101
]
assert
layers
in
supported_layers
,
\
assert
layers
in
supported_layers
,
\
"supported layers are {} but input layer is {}"
.
format
(
"supported layers are {} but input layer is {}"
.
format
(
supported_layers
,
layers
)
supported_layers
,
layers
)
if
layers
==
18
:
if
layers
==
50
:
depth
=
[
2
,
2
,
2
,
2
]
elif
layers
==
34
or
layers
==
50
:
depth
=
[
3
,
3
,
5
,
2
]
depth
=
[
3
,
3
,
5
,
2
]
elif
layers
==
101
:
elif
layers
==
101
:
depth
=
[
3
,
4
,
23
,
3
]
depth
=
[
3
,
3
,
22
,
2
]
elif
layers
==
152
:
depth
=
[
3
,
8
,
36
,
3
]
num_filters
=
[
64
,
128
,
256
,
512
]
num_filters
=
[
64
,
128
,
256
,
512
]
conv
=
self
.
conv_bn_layer
(
conv
=
self
.
conv_bn_layer
(
...
@@ -62,7 +58,6 @@ class CSPResNet():
...
@@ -62,7 +58,6 @@ class CSPResNet():
pool_type
=
'max'
,
pool_type
=
'max'
,
data_format
=
data_format
)
data_format
=
data_format
)
if
layers
>=
50
:
for
block
in
range
(
len
(
depth
)):
for
block
in
range
(
len
(
depth
)):
conv_name
=
"res"
+
str
(
block
+
2
)
+
chr
(
97
)
conv_name
=
"res"
+
str
(
block
+
2
)
+
chr
(
97
)
if
block
!=
0
:
if
block
!=
0
:
...
@@ -75,11 +70,7 @@ class CSPResNet():
...
@@ -75,11 +70,7 @@ class CSPResNet():
name
=
conv_name
+
"_downsample"
,
name
=
conv_name
+
"_downsample"
,
data_format
=
data_format
)
data_format
=
data_format
)
# layer warp
# split
# left, right = fluid.layers.split(
# conv,
# num_or_sections=[conv.shape[1]//2, conv.shape[1]//2],
# dim=1)
left
=
conv
left
=
conv
right
=
conv
right
=
conv
if
block
==
0
:
if
block
==
0
:
...
@@ -129,8 +120,6 @@ class CSPResNet():
...
@@ -129,8 +120,6 @@ class CSPResNet():
act
=
"leaky_relu"
,
act
=
"leaky_relu"
,
name
=
conv_name
+
"_merged_transition"
,
name
=
conv_name
+
"_merged_transition"
,
data_format
=
data_format
)
data_format
=
data_format
)
else
:
assert
False
,
"not implemented now!!!"
pool
=
fluid
.
layers
.
pool2d
(
pool
=
fluid
.
layers
.
pool2d
(
input
=
conv
,
input
=
conv
,
...
@@ -193,7 +182,7 @@ class CSPResNet():
...
@@ -193,7 +182,7 @@ class CSPResNet():
ch_in
=
input
.
shape
[
1
]
ch_in
=
input
.
shape
[
1
]
else
:
else
:
ch_in
=
input
.
shape
[
-
1
]
ch_in
=
input
.
shape
[
-
1
]
if
ch_in
!=
ch_out
or
stride
!=
1
or
is_first
==
True
:
if
ch_in
!=
ch_out
or
stride
!=
1
or
is_first
is
True
:
return
self
.
conv_bn_layer
(
return
self
.
conv_bn_layer
(
input
,
ch_out
,
1
,
stride
,
name
=
name
,
data_format
=
data_format
)
input
,
ch_out
,
1
,
stride
,
name
=
name
,
data_format
=
data_format
)
else
:
else
:
...
@@ -239,3 +228,8 @@ class CSPResNet():
...
@@ -239,3 +228,8 @@ class CSPResNet():
def
CSPResNet50
():
def
CSPResNet50
():
model
=
CSPResNet
(
layers
=
50
)
model
=
CSPResNet
(
layers
=
50
)
return
model
return
model
def
CSPResNet101
():
model
=
CSPResNet
(
layers
=
101
)
return
model
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录