Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
6670f50a
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看板
提交
6670f50a
编写于
4月 22, 2022
作者:
L
LDOUBLEV
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add cafpn
上级
d7b107d1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
3 deletion
+76
-3
ppocr/modeling/necks/__init__.py
ppocr/modeling/necks/__init__.py
+3
-3
ppocr/modeling/necks/db_fpn.py
ppocr/modeling/necks/db_fpn.py
+73
-0
未找到文件。
ppocr/modeling/necks/__init__.py
浏览文件 @
6670f50a
...
...
@@ -16,7 +16,7 @@ __all__ = ['build_neck']
def
build_neck
(
config
):
from
.db_fpn
import
DBFPN
from
.db_fpn
import
DBFPN
,
CAFPN
from
.east_fpn
import
EASTFPN
from
.sast_fpn
import
SASTFPN
from
.rnn
import
SequenceEncoder
...
...
@@ -26,8 +26,8 @@ def build_neck(config):
from
.fce_fpn
import
FCEFPN
from
.pren_fpn
import
PRENFPN
support_dict
=
[
'FPN'
,
'FCEFPN'
,
'DBFPN'
,
'
EASTFPN'
,
'SASTFPN'
,
'SequenceEncoder
'
,
'PGFPN'
,
'TableFPN'
,
'PRENFPN'
'FPN'
,
'FCEFPN'
,
'DBFPN'
,
'
CAFPN'
,
'EASTFPN'
,
'SASTFPN
'
,
'
SequenceEncoder'
,
'
PGFPN'
,
'TableFPN'
,
'PRENFPN'
]
module_name
=
config
.
pop
(
'name'
)
...
...
ppocr/modeling/necks/db_fpn.py
浏览文件 @
6670f50a
...
...
@@ -20,6 +20,7 @@ import paddle
from
paddle
import
nn
import
paddle.nn.functional
as
F
from
paddle
import
ParamAttr
from
ppocr.backbones.det_mobilenet_v3
import
SEModule
class
DBFPN
(
nn
.
Layer
):
...
...
@@ -106,3 +107,75 @@ class DBFPN(nn.Layer):
fuse
=
paddle
.
concat
([
p5
,
p4
,
p3
,
p2
],
axis
=
1
)
return
fuse
class
CALayer
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
kernel_size
,
shortcut
=
True
):
super
(
CALayer
,
self
).
__init__
()
weight_attr
=
paddle
.
nn
.
initializer
.
KaimingUniform
()
self
.
in_conv
=
nn
.
Conv2D
(
in_channels
=
in_channels
,
out_channels
=
self
.
out_channels
,
kernel_size
=
kernel_size
,
padding
=
int
(
kernel_size
//
2
),
weight_attr
=
ParamAttr
(
initializer
=
weight_attr
),
bias_attr
=
False
)
self
.
se_block
=
SEModule
(
self
.
out_channels
)
self
.
shortcut
=
shortcut
def
forward
(
self
,
ins
):
x
=
self
.
in_conv
(
ins
)
if
self
.
shortcut
:
out
=
x
+
self
.
se_block
(
x
)
else
:
out
=
self
.
se_block
(
x
)
return
out
class
CAFPN
(
nn
.
Layer
):
def
__init__
(
self
,
in_channels
,
out_channels
,
shortcut
,
**
kwargs
):
super
(
CAFPN
,
self
).
__init__
()
self
.
ins_convs
=
[]
self
.
inp_convs
=
[]
for
i
in
range
(
len
(
in_channels
)):
self
.
ins_conv
.
append
(
CALayer
(
in_channels
[
i
],
out_channels
,
kernel_size
=
1
,
shortcut
=
shortcut
))
self
.
inp_conv
.
append
(
CALayer
(
out_channels
,
out_channels
//
4
,
kernel_size
=
3
,
shortcut
=
shortcut
))
def
forward
(
self
,
x
):
c2
,
c3
,
c4
,
c5
=
x
in5
=
self
.
ins_conv
[
3
](
c5
)
in4
=
self
.
ins_conv
[
2
](
c4
)
in3
=
self
.
ins_conv
[
1
](
c3
)
in2
=
self
.
ins_conv
[
0
](
c2
)
out4
=
in4
+
F
.
upsample
(
in5
,
scale_factor
=
2
,
mode
=
"nearest"
,
align_mode
=
1
)
# 1/16
out3
=
in3
+
F
.
upsample
(
out4
,
scale_factor
=
2
,
mode
=
"nearest"
,
align_mode
=
1
)
# 1/8
out2
=
in2
+
F
.
upsample
(
out3
,
scale_factor
=
2
,
mode
=
"nearest"
,
align_mode
=
1
)
# 1/4
p5
=
self
.
inp_conv
[
3
](
in5
)
p4
=
self
.
inp_conv
[
2
](
out4
)
p3
=
self
.
inp_conv
[
1
](
out3
)
p2
=
self
.
inp_conv
[
0
](
out2
)
p5
=
F
.
upsample
(
p5
,
scale_factor
=
8
,
mode
=
"nearest"
,
align_mode
=
1
)
p4
=
F
.
upsample
(
p4
,
scale_factor
=
4
,
mode
=
"nearest"
,
align_mode
=
1
)
p3
=
F
.
upsample
(
p3
,
scale_factor
=
2
,
mode
=
"nearest"
,
align_mode
=
1
)
fuse
=
paddle
.
concat
([
p5
,
p4
,
p3
,
p2
],
axis
=
1
)
return
fuse
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录