Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
2b8e9b26
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
2b8e9b26
编写于
12月 08, 2021
作者:
littletomatodonkey
提交者:
GitHub
12月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove name (#4870)
上级
b1693f54
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
63 deletion
+29
-63
ppocr/modeling/backbones/det_resnet_vd.py
ppocr/modeling/backbones/det_resnet_vd.py
+29
-63
未找到文件。
ppocr/modeling/backbones/det_resnet_vd.py
浏览文件 @
2b8e9b26
...
@@ -25,16 +25,14 @@ __all__ = ["ResNet"]
...
@@ -25,16 +25,14 @@ __all__ = ["ResNet"]
class
ConvBNLayer
(
nn
.
Layer
):
class
ConvBNLayer
(
nn
.
Layer
):
def
__init__
(
def
__init__
(
self
,
self
,
in_channels
,
in_channels
,
out_channels
,
out_channels
,
kernel_size
,
kernel_size
,
stride
=
1
,
stride
=
1
,
groups
=
1
,
groups
=
1
,
is_vd_mode
=
False
,
is_vd_mode
=
False
,
act
=
None
):
act
=
None
,
name
=
None
,
):
super
(
ConvBNLayer
,
self
).
__init__
()
super
(
ConvBNLayer
,
self
).
__init__
()
self
.
is_vd_mode
=
is_vd_mode
self
.
is_vd_mode
=
is_vd_mode
...
@@ -47,19 +45,8 @@ class ConvBNLayer(nn.Layer):
...
@@ -47,19 +45,8 @@ class ConvBNLayer(nn.Layer):
stride
=
stride
,
stride
=
stride
,
padding
=
(
kernel_size
-
1
)
//
2
,
padding
=
(
kernel_size
-
1
)
//
2
,
groups
=
groups
,
groups
=
groups
,
weight_attr
=
ParamAttr
(
name
=
name
+
"_weights"
),
bias_attr
=
False
)
bias_attr
=
False
)
if
name
==
"conv1"
:
self
.
_batch_norm
=
nn
.
BatchNorm
(
out_channels
,
act
=
act
)
bn_name
=
"bn_"
+
name
else
:
bn_name
=
"bn"
+
name
[
3
:]
self
.
_batch_norm
=
nn
.
BatchNorm
(
out_channels
,
act
=
act
,
param_attr
=
ParamAttr
(
name
=
bn_name
+
'_scale'
),
bias_attr
=
ParamAttr
(
bn_name
+
'_offset'
),
moving_mean_name
=
bn_name
+
'_mean'
,
moving_variance_name
=
bn_name
+
'_variance'
)
def
forward
(
self
,
inputs
):
def
forward
(
self
,
inputs
):
if
self
.
is_vd_mode
:
if
self
.
is_vd_mode
:
...
@@ -75,29 +62,25 @@ class BottleneckBlock(nn.Layer):
...
@@ -75,29 +62,25 @@ class BottleneckBlock(nn.Layer):
out_channels
,
out_channels
,
stride
,
stride
,
shortcut
=
True
,
shortcut
=
True
,
if_first
=
False
,
if_first
=
False
):
name
=
None
):
super
(
BottleneckBlock
,
self
).
__init__
()
super
(
BottleneckBlock
,
self
).
__init__
()
self
.
conv0
=
ConvBNLayer
(
self
.
conv0
=
ConvBNLayer
(
in_channels
=
in_channels
,
in_channels
=
in_channels
,
out_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
1
,
kernel_size
=
1
,
act
=
'relu'
,
act
=
'relu'
)
name
=
name
+
"_branch2a"
)
self
.
conv1
=
ConvBNLayer
(
self
.
conv1
=
ConvBNLayer
(
in_channels
=
out_channels
,
in_channels
=
out_channels
,
out_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
3
,
kernel_size
=
3
,
stride
=
stride
,
stride
=
stride
,
act
=
'relu'
,
act
=
'relu'
)
name
=
name
+
"_branch2b"
)
self
.
conv2
=
ConvBNLayer
(
self
.
conv2
=
ConvBNLayer
(
in_channels
=
out_channels
,
in_channels
=
out_channels
,
out_channels
=
out_channels
*
4
,
out_channels
=
out_channels
*
4
,
kernel_size
=
1
,
kernel_size
=
1
,
act
=
None
,
act
=
None
)
name
=
name
+
"_branch2c"
)
if
not
shortcut
:
if
not
shortcut
:
self
.
short
=
ConvBNLayer
(
self
.
short
=
ConvBNLayer
(
...
@@ -105,8 +88,7 @@ class BottleneckBlock(nn.Layer):
...
@@ -105,8 +88,7 @@ class BottleneckBlock(nn.Layer):
out_channels
=
out_channels
*
4
,
out_channels
=
out_channels
*
4
,
kernel_size
=
1
,
kernel_size
=
1
,
stride
=
1
,
stride
=
1
,
is_vd_mode
=
False
if
if_first
else
True
,
is_vd_mode
=
False
if
if_first
else
True
)
name
=
name
+
"_branch1"
)
self
.
shortcut
=
shortcut
self
.
shortcut
=
shortcut
...
@@ -125,13 +107,13 @@ class BottleneckBlock(nn.Layer):
...
@@ -125,13 +107,13 @@ class BottleneckBlock(nn.Layer):
class
BasicBlock
(
nn
.
Layer
):
class
BasicBlock
(
nn
.
Layer
):
def
__init__
(
self
,
def
__init__
(
in_channels
,
self
,
out
_channels
,
in
_channels
,
stride
,
out_channels
,
shortcut
=
Tru
e
,
strid
e
,
if_first
=
Fals
e
,
shortcut
=
Tru
e
,
name
=
None
):
if_first
=
False
,
):
super
(
BasicBlock
,
self
).
__init__
()
super
(
BasicBlock
,
self
).
__init__
()
self
.
stride
=
stride
self
.
stride
=
stride
self
.
conv0
=
ConvBNLayer
(
self
.
conv0
=
ConvBNLayer
(
...
@@ -139,14 +121,12 @@ class BasicBlock(nn.Layer):
...
@@ -139,14 +121,12 @@ class BasicBlock(nn.Layer):
out_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
3
,
kernel_size
=
3
,
stride
=
stride
,
stride
=
stride
,
act
=
'relu'
,
act
=
'relu'
)
name
=
name
+
"_branch2a"
)
self
.
conv1
=
ConvBNLayer
(
self
.
conv1
=
ConvBNLayer
(
in_channels
=
out_channels
,
in_channels
=
out_channels
,
out_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
3
,
kernel_size
=
3
,
act
=
None
,
act
=
None
)
name
=
name
+
"_branch2b"
)
if
not
shortcut
:
if
not
shortcut
:
self
.
short
=
ConvBNLayer
(
self
.
short
=
ConvBNLayer
(
...
@@ -154,8 +134,7 @@ class BasicBlock(nn.Layer):
...
@@ -154,8 +134,7 @@ class BasicBlock(nn.Layer):
out_channels
=
out_channels
,
out_channels
=
out_channels
,
kernel_size
=
1
,
kernel_size
=
1
,
stride
=
1
,
stride
=
1
,
is_vd_mode
=
False
if
if_first
else
True
,
is_vd_mode
=
False
if
if_first
else
True
)
name
=
name
+
"_branch1"
)
self
.
shortcut
=
shortcut
self
.
shortcut
=
shortcut
...
@@ -201,22 +180,19 @@ class ResNet(nn.Layer):
...
@@ -201,22 +180,19 @@ class ResNet(nn.Layer):
out_channels
=
32
,
out_channels
=
32
,
kernel_size
=
3
,
kernel_size
=
3
,
stride
=
2
,
stride
=
2
,
act
=
'relu'
,
act
=
'relu'
)
name
=
"conv1_1"
)
self
.
conv1_2
=
ConvBNLayer
(
self
.
conv1_2
=
ConvBNLayer
(
in_channels
=
32
,
in_channels
=
32
,
out_channels
=
32
,
out_channels
=
32
,
kernel_size
=
3
,
kernel_size
=
3
,
stride
=
1
,
stride
=
1
,
act
=
'relu'
,
act
=
'relu'
)
name
=
"conv1_2"
)
self
.
conv1_3
=
ConvBNLayer
(
self
.
conv1_3
=
ConvBNLayer
(
in_channels
=
32
,
in_channels
=
32
,
out_channels
=
64
,
out_channels
=
64
,
kernel_size
=
3
,
kernel_size
=
3
,
stride
=
1
,
stride
=
1
,
act
=
'relu'
,
act
=
'relu'
)
name
=
"conv1_3"
)
self
.
pool2d_max
=
nn
.
MaxPool2D
(
kernel_size
=
3
,
stride
=
2
,
padding
=
1
)
self
.
pool2d_max
=
nn
.
MaxPool2D
(
kernel_size
=
3
,
stride
=
2
,
padding
=
1
)
self
.
stages
=
[]
self
.
stages
=
[]
...
@@ -226,13 +202,6 @@ class ResNet(nn.Layer):
...
@@ -226,13 +202,6 @@ class ResNet(nn.Layer):
block_list
=
[]
block_list
=
[]
shortcut
=
False
shortcut
=
False
for
i
in
range
(
depth
[
block
]):
for
i
in
range
(
depth
[
block
]):
if
layers
in
[
101
,
152
]
and
block
==
2
:
if
i
==
0
:
conv_name
=
"res"
+
str
(
block
+
2
)
+
"a"
else
:
conv_name
=
"res"
+
str
(
block
+
2
)
+
"b"
+
str
(
i
)
else
:
conv_name
=
"res"
+
str
(
block
+
2
)
+
chr
(
97
+
i
)
bottleneck_block
=
self
.
add_sublayer
(
bottleneck_block
=
self
.
add_sublayer
(
'bb_%d_%d'
%
(
block
,
i
),
'bb_%d_%d'
%
(
block
,
i
),
BottleneckBlock
(
BottleneckBlock
(
...
@@ -241,8 +210,7 @@ class ResNet(nn.Layer):
...
@@ -241,8 +210,7 @@ class ResNet(nn.Layer):
out_channels
=
num_filters
[
block
],
out_channels
=
num_filters
[
block
],
stride
=
2
if
i
==
0
and
block
!=
0
else
1
,
stride
=
2
if
i
==
0
and
block
!=
0
else
1
,
shortcut
=
shortcut
,
shortcut
=
shortcut
,
if_first
=
block
==
i
==
0
,
if_first
=
block
==
i
==
0
))
name
=
conv_name
))
shortcut
=
True
shortcut
=
True
block_list
.
append
(
bottleneck_block
)
block_list
.
append
(
bottleneck_block
)
self
.
out_channels
.
append
(
num_filters
[
block
]
*
4
)
self
.
out_channels
.
append
(
num_filters
[
block
]
*
4
)
...
@@ -252,7 +220,6 @@ class ResNet(nn.Layer):
...
@@ -252,7 +220,6 @@ class ResNet(nn.Layer):
block_list
=
[]
block_list
=
[]
shortcut
=
False
shortcut
=
False
for
i
in
range
(
depth
[
block
]):
for
i
in
range
(
depth
[
block
]):
conv_name
=
"res"
+
str
(
block
+
2
)
+
chr
(
97
+
i
)
basic_block
=
self
.
add_sublayer
(
basic_block
=
self
.
add_sublayer
(
'bb_%d_%d'
%
(
block
,
i
),
'bb_%d_%d'
%
(
block
,
i
),
BasicBlock
(
BasicBlock
(
...
@@ -261,8 +228,7 @@ class ResNet(nn.Layer):
...
@@ -261,8 +228,7 @@ class ResNet(nn.Layer):
out_channels
=
num_filters
[
block
],
out_channels
=
num_filters
[
block
],
stride
=
2
if
i
==
0
and
block
!=
0
else
1
,
stride
=
2
if
i
==
0
and
block
!=
0
else
1
,
shortcut
=
shortcut
,
shortcut
=
shortcut
,
if_first
=
block
==
i
==
0
,
if_first
=
block
==
i
==
0
))
name
=
conv_name
))
shortcut
=
True
shortcut
=
True
block_list
.
append
(
basic_block
)
block_list
.
append
(
basic_block
)
self
.
out_channels
.
append
(
num_filters
[
block
])
self
.
out_channels
.
append
(
num_filters
[
block
])
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录