Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
38031eb4
Unverified
Commit
38031eb4
authored
Jan 26, 2021
by
littletomatodonkey
Committed by
GitHub
Jan 26, 2021
Browse files
Revert "Revert "fix mv3 to adapt to paddle2.0""
parent
5a5d627d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
42 deletions
+43
-42
ppocr/modeling/backbones/det_mobilenet_v3.py
ppocr/modeling/backbones/det_mobilenet_v3.py
+24
-23
ppocr/modeling/backbones/rec_mobilenet_v3.py
ppocr/modeling/backbones/rec_mobilenet_v3.py
+19
-19
No files found.
ppocr/modeling/backbones/det_mobilenet_v3.py
View file @
38031eb4
...
...
@@ -58,15 +58,15 @@ class MobileNetV3(nn.Layer):
[
5
,
72
,
40
,
True
,
'relu'
,
2
],
[
5
,
120
,
40
,
True
,
'relu'
,
1
],
[
5
,
120
,
40
,
True
,
'relu'
,
1
],
[
3
,
240
,
80
,
False
,
'hard
_
swish'
,
2
],
[
3
,
200
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
184
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
184
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
480
,
112
,
True
,
'hard
_
swish'
,
1
],
[
3
,
672
,
112
,
True
,
'hard
_
swish'
,
1
],
[
5
,
672
,
160
,
True
,
'hard
_
swish'
,
2
],
[
5
,
960
,
160
,
True
,
'hard
_
swish'
,
1
],
[
5
,
960
,
160
,
True
,
'hard
_
swish'
,
1
],
[
3
,
240
,
80
,
False
,
'hardswish'
,
2
],
[
3
,
200
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
184
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
184
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
480
,
112
,
True
,
'hardswish'
,
1
],
[
3
,
672
,
112
,
True
,
'hardswish'
,
1
],
[
5
,
672
,
160
,
True
,
'hardswish'
,
2
],
[
5
,
960
,
160
,
True
,
'hardswish'
,
1
],
[
5
,
960
,
160
,
True
,
'hardswish'
,
1
],
]
cls_ch_squeeze
=
960
elif
model_name
==
"small"
:
...
...
@@ -75,14 +75,14 @@ class MobileNetV3(nn.Layer):
[
3
,
16
,
16
,
True
,
'relu'
,
2
],
[
3
,
72
,
24
,
False
,
'relu'
,
2
],
[
3
,
88
,
24
,
False
,
'relu'
,
1
],
[
5
,
96
,
40
,
True
,
'hard
_
swish'
,
2
],
[
5
,
240
,
40
,
True
,
'hard
_
swish'
,
1
],
[
5
,
240
,
40
,
True
,
'hard
_
swish'
,
1
],
[
5
,
120
,
48
,
True
,
'hard
_
swish'
,
1
],
[
5
,
144
,
48
,
True
,
'hard
_
swish'
,
1
],
[
5
,
288
,
96
,
True
,
'hard
_
swish'
,
2
],
[
5
,
576
,
96
,
True
,
'hard
_
swish'
,
1
],
[
5
,
576
,
96
,
True
,
'hard
_
swish'
,
1
],
[
5
,
96
,
40
,
True
,
'hardswish'
,
2
],
[
5
,
240
,
40
,
True
,
'hardswish'
,
1
],
[
5
,
240
,
40
,
True
,
'hardswish'
,
1
],
[
5
,
120
,
48
,
True
,
'hardswish'
,
1
],
[
5
,
144
,
48
,
True
,
'hardswish'
,
1
],
[
5
,
288
,
96
,
True
,
'hardswish'
,
2
],
[
5
,
576
,
96
,
True
,
'hardswish'
,
1
],
[
5
,
576
,
96
,
True
,
'hardswish'
,
1
],
]
cls_ch_squeeze
=
576
else
:
...
...
@@ -102,7 +102,7 @@ class MobileNetV3(nn.Layer):
padding
=
1
,
groups
=
1
,
if_act
=
True
,
act
=
'hard
_
swish'
,
act
=
'hardswish'
,
name
=
'conv1'
)
self
.
stages
=
[]
...
...
@@ -137,7 +137,7 @@ class MobileNetV3(nn.Layer):
padding
=
0
,
groups
=
1
,
if_act
=
True
,
act
=
'hard
_
swish'
,
act
=
'hardswish'
,
name
=
'conv_last'
))
self
.
stages
.
append
(
nn
.
Sequential
(
*
block_list
))
self
.
out_channels
.
append
(
make_divisible
(
scale
*
cls_ch_squeeze
))
...
...
@@ -191,10 +191,11 @@ class ConvBNLayer(nn.Layer):
if
self
.
if_act
:
if
self
.
act
==
"relu"
:
x
=
F
.
relu
(
x
)
elif
self
.
act
==
"hard
_
swish"
:
x
=
F
.
activation
.
hard
_
swish
(
x
)
elif
self
.
act
==
"hardswish"
:
x
=
F
.
hardswish
(
x
)
else
:
print
(
"The activation function is selected incorrectly."
)
print
(
"The activation function({}) is selected incorrectly."
.
format
(
self
.
act
))
exit
()
return
x
...
...
@@ -281,5 +282,5 @@ class SEModule(nn.Layer):
outputs
=
self
.
conv1
(
outputs
)
outputs
=
F
.
relu
(
outputs
)
outputs
=
self
.
conv2
(
outputs
)
outputs
=
F
.
activation
.
hard
_
sigmoid
(
outputs
)
outputs
=
F
.
hardsigmoid
(
outputs
,
slope
=
0.2
,
offset
=
0.5
)
return
inputs
*
outputs
ppocr/modeling/backbones/rec_mobilenet_v3.py
View file @
38031eb4
...
...
@@ -51,15 +51,15 @@ class MobileNetV3(nn.Layer):
[
5
,
72
,
40
,
True
,
'relu'
,
(
large_stride
[
2
],
1
)],
[
5
,
120
,
40
,
True
,
'relu'
,
1
],
[
5
,
120
,
40
,
True
,
'relu'
,
1
],
[
3
,
240
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
200
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
184
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
184
,
80
,
False
,
'hard
_
swish'
,
1
],
[
3
,
480
,
112
,
True
,
'hard
_
swish'
,
1
],
[
3
,
672
,
112
,
True
,
'hard
_
swish'
,
1
],
[
5
,
672
,
160
,
True
,
'hard
_
swish'
,
(
large_stride
[
3
],
1
)],
[
5
,
960
,
160
,
True
,
'hard
_
swish'
,
1
],
[
5
,
960
,
160
,
True
,
'hard
_
swish'
,
1
],
[
3
,
240
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
200
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
184
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
184
,
80
,
False
,
'hardswish'
,
1
],
[
3
,
480
,
112
,
True
,
'hardswish'
,
1
],
[
3
,
672
,
112
,
True
,
'hardswish'
,
1
],
[
5
,
672
,
160
,
True
,
'hardswish'
,
(
large_stride
[
3
],
1
)],
[
5
,
960
,
160
,
True
,
'hardswish'
,
1
],
[
5
,
960
,
160
,
True
,
'hardswish'
,
1
],
]
cls_ch_squeeze
=
960
elif
model_name
==
"small"
:
...
...
@@ -68,14 +68,14 @@ class MobileNetV3(nn.Layer):
[
3
,
16
,
16
,
True
,
'relu'
,
(
small_stride
[
0
],
1
)],
[
3
,
72
,
24
,
False
,
'relu'
,
(
small_stride
[
1
],
1
)],
[
3
,
88
,
24
,
False
,
'relu'
,
1
],
[
5
,
96
,
40
,
True
,
'hard
_
swish'
,
(
small_stride
[
2
],
1
)],
[
5
,
240
,
40
,
True
,
'hard
_
swish'
,
1
],
[
5
,
240
,
40
,
True
,
'hard
_
swish'
,
1
],
[
5
,
120
,
48
,
True
,
'hard
_
swish'
,
1
],
[
5
,
144
,
48
,
True
,
'hard
_
swish'
,
1
],
[
5
,
288
,
96
,
True
,
'hard
_
swish'
,
(
small_stride
[
3
],
1
)],
[
5
,
576
,
96
,
True
,
'hard
_
swish'
,
1
],
[
5
,
576
,
96
,
True
,
'hard
_
swish'
,
1
],
[
5
,
96
,
40
,
True
,
'hardswish'
,
(
small_stride
[
2
],
1
)],
[
5
,
240
,
40
,
True
,
'hardswish'
,
1
],
[
5
,
240
,
40
,
True
,
'hardswish'
,
1
],
[
5
,
120
,
48
,
True
,
'hardswish'
,
1
],
[
5
,
144
,
48
,
True
,
'hardswish'
,
1
],
[
5
,
288
,
96
,
True
,
'hardswish'
,
(
small_stride
[
3
],
1
)],
[
5
,
576
,
96
,
True
,
'hardswish'
,
1
],
[
5
,
576
,
96
,
True
,
'hardswish'
,
1
],
]
cls_ch_squeeze
=
576
else
:
...
...
@@ -96,7 +96,7 @@ class MobileNetV3(nn.Layer):
padding
=
1
,
groups
=
1
,
if_act
=
True
,
act
=
'hard
_
swish'
,
act
=
'hardswish'
,
name
=
'conv1'
)
i
=
0
block_list
=
[]
...
...
@@ -124,7 +124,7 @@ class MobileNetV3(nn.Layer):
padding
=
0
,
groups
=
1
,
if_act
=
True
,
act
=
'hard
_
swish'
,
act
=
'hardswish'
,
name
=
'conv_last'
)
self
.
pool
=
nn
.
MaxPool2D
(
kernel_size
=
2
,
stride
=
2
,
padding
=
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment