Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
871f6162
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看板
未验证
提交
871f6162
编写于
2月 06, 2020
作者:
R
Rosun
提交者:
GitHub
2月 06, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete bak files for SemSegPaddle (#4244)
delete bak files for SemSegPaddle
上级
0990636b
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
3 addition
and
29697 deletion
+3
-29697
PaddleCV/Research/SemSegPaddle/src/models/modeling/glore.py.bak
...CV/Research/SemSegPaddle/src/models/modeling/glore.py.bak
+0
-115
PaddleCV/Research/SemSegPaddle/src/models/modeling/glore.py.bak1
...V/Research/SemSegPaddle/src/models/modeling/glore.py.bak1
+0
-119
PaddleCV/Research/SemSegPaddle/train.log
PaddleCV/Research/SemSegPaddle/train.log
+0
-29460
README.md
README.md
+3
-3
未找到文件。
PaddleCV/Research/SemSegPaddle/src/models/modeling/glore.py.bak
已删除
100644 → 0
浏览文件 @
0990636b
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
import
paddle
.
fluid
as
fluid
from
paddle
.
fluid
.
param_attr
import
ParamAttr
from
src
.
models
.
libs
.
model_libs
import
scope
,
name_scope
from
src
.
models
.
libs
.
model_libs
import
avg_pool
,
conv
,
bn
,
conv1d
,
FCNHead
from
src
.
models
.
backbone
.
resnet
import
ResNet
as
resnet_backbone
from
src
.
utils
.
config
import
cfg
def
get_logit_interp
(
input
,
num_classes
,
out_shape
,
name
=
"logit"
):
#
根据类别数决定最后一层卷积输出
,
并插值回原始尺寸
param_attr
=
fluid
.
ParamAttr
(
name
=
name
+
'weights'
,
regularizer
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.0
),
initializer
=
fluid
.
initializer
.
TruncatedNormal
(
loc
=
0.0
,
scale
=
0.01
))
with
scope
(
name
):
logit
=
conv
(
input
,
num_classes
,
filter_size
=
1
,
param_attr
=
param_attr
,
bias_attr
=
True
,
name
=
name
+
'_conv'
)
logit_interp
=
fluid
.
layers
.
resize_bilinear
(
logit
,
out_shape
=
out_shape
,
name
=
name
+
'_interp'
)
return
logit_interp
def
gcn_module
(
name_scope
,
x
,
num_node
,
num_state
):
'''
input: any tensor of 3D, B,C,N
'''
h
=
fluid
.
layers
.
transpose
(
x
,
perm
=[
0
,
2
,
1
])
#
B
,
C
,
N
-->
B
,
N
,
C
h
=
conv1d
(
h
,
num_node
,
name_scope
+
'_conv1d1'
)
h
=
fluid
.
layers
.
transpose
(
h
,
perm
=[
0
,
2
,
1
])
#
B
,
C
,
N
h
=
fluid
.
layers
.
elementwise_add
(
h
,
x
,
act
=
'relu'
)
h
=
conv1d
(
h
,
num_state
,
name_scope
+
'_conv1d2'
)
return
h
def
gru_module
(
x
,
num_state
,
num_node
):
'''
Global Reasoning Unit: projection --> graph reasoning --> reverse projection
params:
x: B x C x H x W
num_state: the dimension of each vertex feature
num_node: the number of vertet
output: B x C x H x W
feature trans:
B, C, H, W --> B, N, H, W --> B, N, H*W -->B, N, C1 -->B, C1, N-->B, C1, N-->B, C1, H*W-->B, C, H, W
--> B, C1,H, W -->B, C1,H*W -->B, H*W, C1
'''
num_batch
,
C
,
H
,
W
=
x
.
shape
with
scope
(
'projection'
):
B
=
conv
(
x
,
num_node
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'projection'
+
'_conv'
)
#
num_batch
,
node
,
H
,
W
B
=
fluid
.
layers
.
reshape
(
B
,
shape
=[
num_batch
,
num_node
,
H
*
W
])
#
num_batch
,
node
,
L
=
H
*
W
with
scope
(
'reduce_channel'
):
x_reduce
=
conv
(
x
,
num_state
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'reduce_channel'
+
'_conv'
)
#
num_batch
,
num_state
,
H
,
W
x_reduce
=
fluid
.
layers
.
reshape
(
x_reduce
,
shape
=[
num_batch
,
num_state
,
H
*
W
])
#
num_batch
,
num_state
,
L
x_reduce
=
fluid
.
layers
.
transpose
(
x_reduce
,
perm
=[
0
,
2
,
1
])
#
num_batch
,
L
,
num_state
V
=
fluid
.
layers
.
transpose
(
fluid
.
layers
.
matmul
(
B
,
x_reduce
),
perm
=[
0
,
2
,
1
])
#
num_batch
,
num_state
,
num_node
new_V
=
gcn_module
(
'gru'
+
'_gcn'
,
V
,
num_node
,
num_state
)
D
=
fluid
.
layers
.
transpose
(
B
,
perm
=[
0
,
2
,
1
])
Y
=
fluid
.
layers
.
matmul
(
D
,
fluid
.
layers
.
transpose
(
new_V
,
perm
=[
0
,
2
,
1
]))
Y
=
fluid
.
layers
.
transpose
(
Y
,
perm
=[
0
,
2
,
1
])
Y
=
fluid
.
layers
.
reshape
(
Y
,
shape
=[
num_batch
,
num_state
,
H
,
W
])
with
scope
(
'extand_dim'
):
Y
=
conv
(
Y
,
C
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'extend_dim'
+
'_conv'
)
Y
=
bn
(
Y
)
out
=
fluid
.
layers
.
elementwise_add
(
Y
,
x
)
return
out
def
resnet
(
input
):
#
PSPNET
backbone
:
resnet
,
默认
resnet50
#
end_points
:
resnet
终止层数
#
dilation_dict
:
resnet
block
数及对应的膨胀卷积尺度
scale
=
cfg
.
MODEL
.
GLORE
.
DEPTH_MULTIPLIER
layers
=
cfg
.
MODEL
.
BACKBONE_LAYERS
end_points
=
layers
-
1
dilation_dict
=
{
2
:
2
,
3
:
4
}
decode_points
=
[
91
,
100
]
model
=
resnet_backbone
(
layers
,
scale
)
res5
,
feat_dict
=
model
.
net
(
input
,
end_points
=
end_points
,
dilation_dict
=
dilation_dict
,
decode_points
=
decode_points
)
return
res5
,
feat_dict
def
glore
(
input
,
num_classes
):
"""
Reference:
Chen, Yunpeng, et al. "
Graph
-
Based
Global
Reasoning
Networks
", In CVPR 2019
"""
#
Backbone
:
ResNet
res5
,
feat_dict
=
resnet
(
input
)
res4
=
feat_dict
[
91
]
#
Conv_1x1
for
reduce
dimension
with
scope
(
'feature'
):
feature
=
conv
(
res5
,
512
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'feature_conv'
)
feature
=
bn
(
feature
,
act
=
'relu'
)
#
GRU
Module
gru_output
=
gru_module
(
feature
,
128
,
64
)
dropout
=
fluid
.
layers
.
dropout
(
gru_output
,
dropout_prob
=
0.1
,
name
=
"dropout"
)
#
根据类别数决定最后一层卷积输出
,
并插值回原始尺寸
logit
=
get_logit_interp
(
dropout
,
num_classes
,
input
.
shape
[
2
:])
if
cfg
.
MODEL
.
GLORE
.
AuxHead
:
aux_logit
=
FCNHead
(
res4
,
256
,
num_classes
,
input
.
shape
[
2
:])
return
logit
,
aux_logit
return
logit
PaddleCV/Research/SemSegPaddle/src/models/modeling/glore.py.bak1
已删除
100644 → 0
浏览文件 @
0990636b
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
sys
import
paddle
.
fluid
as
fluid
from
paddle
.
fluid
.
param_attr
import
ParamAttr
from
src
.
models
.
libs
.
model_libs
import
scope
,
name_scope
from
src
.
models
.
libs
.
model_libs
import
avg_pool
,
conv
,
bn
,
bn_zero
,
conv1d
,
FCNHead
from
src
.
models
.
backbone
.
resnet
import
ResNet
as
resnet_backbone
from
src
.
utils
.
config
import
cfg
def
get_logit_interp
(
input
,
num_classes
,
out_shape
,
name
=
"logit"
):
#
1
x1_Conv
param_attr
=
fluid
.
ParamAttr
(
name
=
name
+
'weights'
,
regularizer
=
fluid
.
regularizer
.
L2DecayRegularizer
(
regularization_coeff
=
0.0
),
initializer
=
fluid
.
initializer
.
TruncatedNormal
(
loc
=
0.0
,
scale
=
0.01
))
with
scope
(
name
):
logit
=
conv
(
input
,
num_classes
,
filter_size
=
1
,
param_attr
=
param_attr
,
bias_attr
=
True
,
name
=
name
+
'_conv'
)
logit_interp
=
fluid
.
layers
.
resize_bilinear
(
logit
,
out_shape
=
out_shape
,
name
=
name
+
'_interp'
)
return
logit_interp
def
gcn_module
(
name_scope
,
x
,
num_node
,
num_state
):
'''
input: any tensor of 3D, B,C,N
'''
print
(
x
.
shape
)
h
=
fluid
.
layers
.
transpose
(
x
,
perm
=[
0
,
2
,
1
])
#
B
,
C
,
N
-->
B
,
N
,
C
h
=
conv1d
(
h
,
num_node
,
name_scope
+
'_conv1d1'
)
h
=
fluid
.
layers
.
transpose
(
h
,
perm
=[
0
,
2
,
1
])
#
B
,
C
,
N
h
=
fluid
.
layers
.
elementwise_add
(
h
,
x
,
act
=
'relu'
)
h
=
conv1d
(
h
,
num_state
,
name_scope
+
'_conv1d2'
)
return
h
def
gru_module
(
x
,
num_state
,
num_node
):
'''
Global Reasoning Unit: projection --> graph reasoning --> reverse projection
params:
x: B x C x H x W
num_state: the dimension of each vertex feature
num_node: the number of vertet
output: B x C x H x W
feature trans:
B, C, H, W --> B, N, H, W --> B, N, H*W -->B, N, C1 -->B, C1, N-->B, C1, N-->B, C1, H*W-->B, C, H, W
--> B, C1,H, W -->B, C1,H*W -->B, H*W, C1
'''
num_batch
,
C
,
H
,
W
=
x
.
shape
with
scope
(
'projection'
):
B
=
conv
(
x
,
num_node
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'projection'
+
'_conv'
)
#
num_batch
,
node
,
H
,
W
B
=
fluid
.
layers
.
reshape
(
B
,
shape
=[
num_batch
,
num_node
,
H
*
W
])
#
num_batch
,
node
,
L
=
H
*
W
with
scope
(
'reduce_channel'
):
x_reduce
=
conv
(
x
,
num_state
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'reduce_channel'
+
'_conv'
)
#
num_batch
,
num_state
,
H
,
W
x_reduce
=
fluid
.
layers
.
reshape
(
x_reduce
,
shape
=[
num_batch
,
num_state
,
H
*
W
])
#
num_batch
,
num_state
,
L
x_reduce
=
fluid
.
layers
.
transpose
(
x_reduce
,
perm
=[
0
,
2
,
1
])
#
num_batch
,
L
,
num_state
V
=
fluid
.
layers
.
transpose
(
fluid
.
layers
.
matmul
(
B
,
x_reduce
),
perm
=[
0
,
2
,
1
])
#
num_batch
,
num_state
,
num_node
L
=
fluid
.
layers
.
fill_constant
(
shape
=[
1
],
value
=
H
*
W
,
dtype
=
'float32'
)
V
=
fluid
.
layers
.
elementwise_div
(
V
,
L
)
new_V
=
gcn_module
(
'gru'
+
'_gcn'
,
V
,
num_node
,
num_state
)
D
=
fluid
.
layers
.
transpose
(
B
,
perm
=[
0
,
2
,
1
])
Y
=
fluid
.
layers
.
matmul
(
D
,
fluid
.
layers
.
transpose
(
new_V
,
perm
=[
0
,
2
,
1
]))
Y
=
fluid
.
layers
.
transpose
(
Y
,
perm
=[
0
,
2
,
1
])
Y
=
fluid
.
layers
.
reshape
(
Y
,
shape
=[
num_batch
,
num_state
,
H
,
W
])
with
scope
(
'extend_dim'
):
Y
=
conv
(
Y
,
C
,
filter_size
=
1
,
bias_attr
=
True
,
name
=
'extend_dim'
+
'_conv'
)
#
Y
=
bn_zero
(
Y
)
Y
=
bn
(
Y
)
out
=
fluid
.
layers
.
elementwise_add
(
Y
,
x
)
return
out
def
resnet
(
input
):
#
end_points
:
end_layer
of
resnet
backbone
#
dilation_dict
:
dilation
factor
for
stages_key
scale
=
cfg
.
MODEL
.
GLORE
.
DEPTH_MULTIPLIER
layers
=
cfg
.
MODEL
.
BACKBONE_LAYERS
end_points
=
layers
-
1
dilation_dict
=
{
2
:
2
,
3
:
4
}
decode_points
=
[
91
,
100
]
model
=
resnet_backbone
(
layers
,
scale
)
res5
,
feat_dict
=
model
.
net
(
input
,
end_points
=
end_points
,
dilation_dict
=
dilation_dict
,
decode_points
=
decode_points
)
return
res5
,
feat_dict
def
glore
(
input
,
num_classes
):
"""
Reference:
Chen, Yunpeng, et al. "
Graph
-
Based
Global
Reasoning
Networks
", In CVPR 2019
"""
#
Backbone
:
ResNet
res5
,
feat_dict
=
resnet
(
input
)
res4
=
feat_dict
[
91
]
#
Conv_1x1
for
reduce
dimension
with
scope
(
'feature'
):
feature
=
conv
(
res5
,
512
,
filter_size
=
3
,
bias_attr
=
True
,
name
=
'feature_conv'
)
feature
=
bn
(
feature
,
act
=
'relu'
)
#
GRU
Module
gru_output
=
gru_module
(
feature
,
128
,
64
)
dropout
=
fluid
.
layers
.
dropout
(
gru_output
,
dropout_prob
=
0.1
,
name
=
"dropout"
)
logit
=
get_logit_interp
(
dropout
,
num_classes
,
input
.
shape
[
2
:])
if
cfg
.
MODEL
.
GLORE
.
AuxHead
:
aux_logit
=
FCNHead
(
res4
,
256
,
num_classes
,
input
.
shape
[
2
:])
return
logit
,
aux_logit
return
logit
PaddleCV/Research/SemSegPaddle/train.log
已删除
100644 → 0
浏览文件 @
0990636b
此差异已折叠。
点击以展开。
README.md
浏览文件 @
871f6162
...
...
@@ -75,9 +75,9 @@ PaddlePaddle 提供了丰富的计算单元,使得用户可以采用模块化
| 模型名称 | 模型简介 | 数据集 | 评估指标 |
| ------------------------------------------------------------ | ------------------------------------------------------------ | --------- | --------------- |
|
[
ICNet
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/icnet
)
| 主要用于图像实时语义分割,能够兼顾速度和准确性,易于线上部署 | Cityscape | Mean IoU=67.0% |
|
[
DeepLab V3+
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/deeplabv3%2B
)
| 通过 encoder-decoder 进行多尺度信息的融合,同时保留了原来的空洞卷积和 ASSP 层, 其骨干网络使用了 Xception 模型,提高了语义分割的健壮性和运行速率 | Cityscape | Mean IoU=78.81% |
|
[
PSPNet (res101)
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/Research/SemSegPaddle
)
| 通过利用不同子区域和全局的上下文信息来增强语义分割质量,同时提出deeply supervised 的辅助loss去改善模型的优化 | Cityscape | Mean IoU = 78.1 |
|
[
ICNet
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/icnet
)
| 主要用于图像实时语义分割,能够兼顾速度和准确性,易于线上部署 | Cityscape
s
| Mean IoU=67.0% |
|
[
DeepLab V3+
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/deeplabv3%2B
)
| 通过 encoder-decoder 进行多尺度信息的融合,同时保留了原来的空洞卷积和 ASSP 层, 其骨干网络使用了 Xception 模型,提高了语义分割的健壮性和运行速率 | Cityscape
s
| Mean IoU=78.81% |
|
[
PSPNet (res101)
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/Research/SemSegPaddle
)
| 通过利用不同子区域和全局的上下文信息来增强语义分割质量,同时提出deeply supervised 的辅助loss去改善模型的优化 | Cityscape
s
| Mean IoU = 78.1 |
|
[
GloRe (res101)
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/Research/SemSegPaddle
)
| 提出一个轻量级的、可端到端训练的全局推理单元GloRe来高效推理image regions之间的关系,增强了模型上下文建模能力| Cityscapes | Mean IoU = 78.4 |
|
[
PSPNet (res101)
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/Research/SemSegPaddle
)
| -| PASCAL Context | Mean IoU = 48.9 |
|
[
GloRe (res101)
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/Research/SemSegPaddle
)
| -| PASCAL Context | Mean IoU = 48.4 |
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录