Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleSeg
提交
2f147565
P
PaddleSeg
项目概览
PaddlePaddle
/
PaddleSeg
通知
287
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
53
列表
看板
标记
里程碑
合并请求
3
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleSeg
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
53
Issue
53
列表
看板
标记
里程碑
合并请求
3
合并请求
3
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2f147565
编写于
9月 24, 2020
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update layer lib
上级
b59a3db5
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
51 addition
and
31 deletion
+51
-31
dygraph/paddleseg/models/common/layer_libs.py
dygraph/paddleseg/models/common/layer_libs.py
+34
-13
dygraph/paddleseg/models/common/pyramid_pool.py
dygraph/paddleseg/models/common/pyramid_pool.py
+2
-2
dygraph/paddleseg/models/deeplab.py
dygraph/paddleseg/models/deeplab.py
+5
-5
dygraph/paddleseg/models/fast_scnn.py
dygraph/paddleseg/models/fast_scnn.py
+10
-11
未找到文件。
dygraph/paddleseg/models/common/layer_libs.py
浏览文件 @
2f147565
...
...
@@ -21,11 +21,17 @@ from paddle.nn import SyncBatchNorm as BatchNorm
class
ConvBNReLU
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
padding
=
'same'
,
**
kwargs
):
super
(
ConvBNReLU
,
self
).
__init__
()
self
.
_conv
=
Conv2d
(
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
)
self
.
_conv
=
Conv2d
(
in_channels
,
out_channels
,
kernel_size
,
padding
=
padding
,
**
kwargs
)
self
.
_batch_norm
=
BatchNorm
(
out_channels
)
...
...
@@ -37,10 +43,16 @@ class ConvBNReLU(nn.Layer):
class
ConvBN
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
padding
=
'same'
,
**
kwargs
):
super
(
ConvBN
,
self
).
__init__
()
self
.
_conv
=
Conv2d
(
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
)
self
.
_conv
=
Conv2d
(
in_channels
,
out_channels
,
kernel_size
,
padding
=
padding
,
**
kwargs
)
self
.
_batch_norm
=
BatchNorm
(
out_channels
)
def
forward
(
self
,
x
):
...
...
@@ -67,17 +79,23 @@ class ConvReluPool(nn.Layer):
return
x
class
DepthwiseConvBNReLU
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
):
super
(
DepthwiseConvBNReLU
,
self
).
__init__
()
class
SeparableConvBNReLU
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
padding
=
'same'
,
**
kwargs
):
super
(
SeparableConvBNReLU
,
self
).
__init__
()
self
.
depthwise_conv
=
ConvBN
(
in_channels
,
out_channels
=
in_channels
,
kernel_size
=
kernel_size
,
padding
=
padding
,
groups
=
in_channels
,
**
kwargs
)
self
.
piontwise_conv
=
ConvBNReLU
(
in_channels
,
out_channels
,
kernel_size
=
1
,
groups
=
1
)
in_channels
,
out_channels
,
kernel_size
=
1
,
padding
=
padding
,
groups
=
1
)
def
forward
(
self
,
x
):
x
=
self
.
depthwise_conv
(
x
)
...
...
@@ -86,20 +104,23 @@ class DepthwiseConvBNReLU(nn.Layer):
class
DepthwiseConvBN
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
**
kwargs
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
padding
=
'same'
,
**
kwargs
):
super
(
DepthwiseConvBN
,
self
).
__init__
()
self
.
depthwise_conv
=
ConvBN
(
in_channels
,
out_channels
=
in
_channels
,
out_channels
=
out
_channels
,
kernel_size
=
kernel_size
,
padding
=
padding
,
groups
=
in_channels
,
**
kwargs
)
self
.
piontwise_conv
=
ConvBN
(
in_channels
,
out_channels
,
kernel_size
=
1
,
groups
=
1
)
def
forward
(
self
,
x
):
x
=
self
.
depthwise_conv
(
x
)
x
=
self
.
piontwise_conv
(
x
)
return
x
...
...
dygraph/paddleseg/models/common/pyramid_pool.py
浏览文件 @
2f147565
...
...
@@ -46,7 +46,7 @@ class ASPPModule(nn.Layer):
for
ratio
in
aspp_ratios
:
if
sep_conv
and
ratio
>
1
:
conv_func
=
layer_libs
.
Depthwis
eConvBNReLU
conv_func
=
layer_libs
.
Separabl
eConvBNReLU
else
:
conv_func
=
layer_libs
.
ConvBNReLU
...
...
dygraph/paddleseg/models/deeplab.py
浏览文件 @
2f147565
...
...
@@ -19,7 +19,7 @@ import paddle.nn.functional as F
from
paddle
import
nn
from
paddleseg.cvlibs
import
manager
from
paddleseg.models.common
import
pyramid_pool
from
paddleseg.models.common.layer_libs
import
ConvBNReLU
,
Depthwis
eConvBNReLU
,
AuxLayer
from
paddleseg.models.common.layer_libs
import
ConvBNReLU
,
Separabl
eConvBNReLU
,
AuxLayer
from
paddleseg.utils
import
utils
__all__
=
[
'DeepLabV3P'
,
'DeepLabV3'
]
...
...
@@ -234,9 +234,9 @@ class Decoder(nn.Layer):
self
.
conv_bn_relu1
=
ConvBNReLU
(
in_channels
=
in_channels
,
out_channels
=
48
,
kernel_size
=
1
)
self
.
conv_bn_relu2
=
Depthwis
eConvBNReLU
(
self
.
conv_bn_relu2
=
Separabl
eConvBNReLU
(
in_channels
=
304
,
out_channels
=
256
,
kernel_size
=
3
,
padding
=
1
)
self
.
conv_bn_relu3
=
Depthwis
eConvBNReLU
(
self
.
conv_bn_relu3
=
Separabl
eConvBNReLU
(
in_channels
=
256
,
out_channels
=
256
,
kernel_size
=
3
,
padding
=
1
)
self
.
conv
=
nn
.
Conv2d
(
in_channels
=
256
,
out_channels
=
num_classes
,
kernel_size
=
1
)
...
...
dygraph/paddleseg/models/fast_scnn.py
浏览文件 @
2f147565
...
...
@@ -17,9 +17,10 @@ from paddle import nn
from
paddleseg.cvlibs
import
manager
from
paddleseg.models.common
import
pyramid_pool
from
paddleseg.models.common.layer_libs
import
ConvBNReLU
,
Depthwis
eConvBNReLU
,
AuxLayer
from
paddleseg.models.common.layer_libs
import
ConvBNReLU
,
Separabl
eConvBNReLU
,
AuxLayer
from
paddleseg.utils
import
utils
@
manager
.
MODELS
.
add_component
class
FastSCNN
(
nn
.
Layer
):
"""
...
...
@@ -40,9 +41,7 @@ class FastSCNN(nn.Layer):
pretrained (str): the path of pretrained model. Default to None.
"""
def
__init__
(
self
,
num_classes
,
enable_auxiliary_loss
=
True
,
def
__init__
(
self
,
num_classes
,
enable_auxiliary_loss
=
True
,
pretrained
=
None
):
super
(
FastSCNN
,
self
).
__init__
()
...
...
@@ -103,13 +102,13 @@ class LearningToDownsample(nn.Layer):
self
.
conv_bn_relu
=
ConvBNReLU
(
in_channels
=
3
,
out_channels
=
dw_channels1
,
kernel_size
=
3
,
stride
=
2
)
self
.
dsconv_bn_relu1
=
Depthwis
eConvBNReLU
(
self
.
dsconv_bn_relu1
=
Separabl
eConvBNReLU
(
in_channels
=
dw_channels1
,
out_channels
=
dw_channels2
,
kernel_size
=
3
,
stride
=
2
,
padding
=
1
)
self
.
dsconv_bn_relu2
=
Depthwis
eConvBNReLU
(
self
.
dsconv_bn_relu2
=
Separabl
eConvBNReLU
(
in_channels
=
dw_channels2
,
out_channels
=
out_channels
,
kernel_size
=
3
,
...
...
@@ -297,13 +296,13 @@ class Classifier(nn.Layer):
def
__init__
(
self
,
input_channels
,
num_classes
):
super
(
Classifier
,
self
).
__init__
()
self
.
dsconv1
=
Depthwis
eConvBNReLU
(
self
.
dsconv1
=
Separabl
eConvBNReLU
(
in_channels
=
input_channels
,
out_channels
=
input_channels
,
kernel_size
=
3
,
padding
=
1
)
self
.
dsconv2
=
Depthwis
eConvBNReLU
(
self
.
dsconv2
=
Separabl
eConvBNReLU
(
in_channels
=
input_channels
,
out_channels
=
input_channels
,
kernel_size
=
3
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录