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
6ded97c7
Commit
6ded97c7
authored
Aug 05, 2021
by
Wei-JL
Committed by
Alchemist_W
Aug 05, 2021
Browse files
Merge branch 'PaddlePaddle:dygraph' into dygraph
去除部分冗余代码
parents
5ce3af84
9b8f587e
Changes
42
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
31 deletions
+54
-31
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+5
-4
tools/infer/utility.py
tools/infer/utility.py
+49
-27
No files found.
tools/infer/predict_rec.py
View file @
6ded97c7
...
...
@@ -73,7 +73,7 @@ class TextRecognizer(object):
model_precision
=
args
.
precision
,
batch_size
=
args
.
rec_batch_num
,
data_shape
=
"dynamic"
,
save_path
=
args
.
save_log_path
,
save_path
=
None
,
#
args.save_log_path,
inference_config
=
self
.
config
,
pids
=
pid
,
process_name
=
None
,
...
...
@@ -81,7 +81,8 @@ class TextRecognizer(object):
time_keys
=
[
'preprocess_time'
,
'inference_time'
,
'postprocess_time'
],
warmup
=
10
)
warmup
=
2
,
logger
=
logger
)
def
resize_norm_img
(
self
,
img
,
max_wh_ratio
):
imgC
,
imgH
,
imgW
=
self
.
rec_image_shape
...
...
@@ -272,10 +273,10 @@ def main(args):
valid_image_file_list
=
[]
img_list
=
[]
# warmup
10
times
# warmup
2
times
if
args
.
warmup
:
img
=
np
.
random
.
uniform
(
0
,
255
,
[
32
,
320
,
3
]).
astype
(
np
.
uint8
)
for
i
in
range
(
10
):
for
i
in
range
(
2
):
res
=
text_recognizer
([
img
])
for
image_file
in
image_file_list
:
...
...
tools/infer/utility.py
View file @
6ded97c7
...
...
@@ -24,6 +24,7 @@ from paddle import inference
import
time
from
ppocr.utils.logging
import
get_logger
def
str2bool
(
v
):
return
v
.
lower
()
in
(
"true"
,
"t"
,
"1"
)
...
...
@@ -47,8 +48,8 @@ def init_args():
# DB parmas
parser
.
add_argument
(
"--det_db_thresh"
,
type
=
float
,
default
=
0.3
)
parser
.
add_argument
(
"--det_db_box_thresh"
,
type
=
float
,
default
=
0.
5
)
parser
.
add_argument
(
"--det_db_unclip_ratio"
,
type
=
float
,
default
=
1.
6
)
parser
.
add_argument
(
"--det_db_box_thresh"
,
type
=
float
,
default
=
0.
6
)
parser
.
add_argument
(
"--det_db_unclip_ratio"
,
type
=
float
,
default
=
1.
5
)
parser
.
add_argument
(
"--max_batch_size"
,
type
=
int
,
default
=
10
)
parser
.
add_argument
(
"--use_dilation"
,
type
=
bool
,
default
=
False
)
parser
.
add_argument
(
"--det_db_score_mode"
,
type
=
str
,
default
=
"fast"
)
...
...
@@ -168,46 +169,67 @@ def create_predictor(args, mode, logger):
if
mode
==
"det"
:
min_input_shape
=
{
"x"
:
[
1
,
3
,
50
,
50
],
"conv2d_92.tmp_0"
:
[
1
,
96
,
20
,
20
],
"conv2d_91.tmp_0"
:
[
1
,
96
,
10
,
10
],
"conv2d_92.tmp_0"
:
[
1
,
120
,
20
,
20
],
"conv2d_91.tmp_0"
:
[
1
,
24
,
10
,
10
],
"conv2d_59.tmp_0"
:
[
1
,
96
,
20
,
20
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
9
6
,
10
,
10
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
9
6
,
20
,
20
],
"conv2d_124.tmp_0"
:
[
1
,
9
6
,
20
,
20
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
2
4
,
20
,
20
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
2
4
,
20
,
20
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
2
4
,
20
,
20
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
25
6
,
10
,
10
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
25
6
,
20
,
20
],
"conv2d_124.tmp_0"
:
[
1
,
25
6
,
20
,
20
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
6
4
,
20
,
20
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
6
4
,
20
,
20
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
6
4
,
20
,
20
],
"elementwise_add_7"
:
[
1
,
56
,
2
,
2
],
"nearest_interp_v2_0.tmp_0"
:
[
1
,
9
6
,
2
,
2
]
"nearest_interp_v2_0.tmp_0"
:
[
1
,
25
6
,
2
,
2
]
}
max_input_shape
=
{
"x"
:
[
1
,
3
,
2000
,
2000
],
"conv2d_92.tmp_0"
:
[
1
,
96
,
400
,
400
],
"conv2d_91.tmp_0"
:
[
1
,
96
,
200
,
200
],
"conv2d_92.tmp_0"
:
[
1
,
120
,
400
,
400
],
"conv2d_91.tmp_0"
:
[
1
,
24
,
200
,
200
],
"conv2d_59.tmp_0"
:
[
1
,
96
,
400
,
400
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
9
6
,
200
,
200
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
25
6
,
200
,
200
],
"conv2d_124.tmp_0"
:
[
1
,
256
,
400
,
400
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
9
6
,
400
,
400
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
2
4
,
400
,
400
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
2
4
,
400
,
400
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
2
4
,
400
,
400
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
25
6
,
400
,
400
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
6
4
,
400
,
400
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
6
4
,
400
,
400
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
6
4
,
400
,
400
],
"elementwise_add_7"
:
[
1
,
56
,
400
,
400
],
"nearest_interp_v2_0.tmp_0"
:
[
1
,
9
6
,
400
,
400
]
"nearest_interp_v2_0.tmp_0"
:
[
1
,
25
6
,
400
,
400
]
}
opt_input_shape
=
{
"x"
:
[
1
,
3
,
640
,
640
],
"conv2d_92.tmp_0"
:
[
1
,
96
,
160
,
160
],
"conv2d_91.tmp_0"
:
[
1
,
96
,
80
,
80
],
"conv2d_92.tmp_0"
:
[
1
,
120
,
160
,
160
],
"conv2d_91.tmp_0"
:
[
1
,
24
,
80
,
80
],
"conv2d_59.tmp_0"
:
[
1
,
96
,
160
,
160
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
9
6
,
80
,
80
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
9
6
,
160
,
160
],
"nearest_interp_v2_1.tmp_0"
:
[
1
,
25
6
,
80
,
80
],
"nearest_interp_v2_2.tmp_0"
:
[
1
,
25
6
,
160
,
160
],
"conv2d_124.tmp_0"
:
[
1
,
256
,
160
,
160
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
2
4
,
160
,
160
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
2
4
,
160
,
160
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
2
4
,
160
,
160
],
"nearest_interp_v2_3.tmp_0"
:
[
1
,
6
4
,
160
,
160
],
"nearest_interp_v2_4.tmp_0"
:
[
1
,
6
4
,
160
,
160
],
"nearest_interp_v2_5.tmp_0"
:
[
1
,
6
4
,
160
,
160
],
"elementwise_add_7"
:
[
1
,
56
,
40
,
40
],
"nearest_interp_v2_0.tmp_0"
:
[
1
,
96
,
40
,
40
]
"nearest_interp_v2_0.tmp_0"
:
[
1
,
256
,
40
,
40
]
}
min_pact_shape
=
{
"nearest_interp_v2_26.tmp_0"
:[
1
,
256
,
20
,
20
],
"nearest_interp_v2_27.tmp_0"
:[
1
,
64
,
20
,
20
],
"nearest_interp_v2_28.tmp_0"
:[
1
,
64
,
20
,
20
],
"nearest_interp_v2_29.tmp_0"
:[
1
,
64
,
20
,
20
]
}
max_pact_shape
=
{
"nearest_interp_v2_26.tmp_0"
:[
1
,
256
,
400
,
400
],
"nearest_interp_v2_27.tmp_0"
:[
1
,
64
,
400
,
400
],
"nearest_interp_v2_28.tmp_0"
:[
1
,
64
,
400
,
400
],
"nearest_interp_v2_29.tmp_0"
:[
1
,
64
,
400
,
400
]
}
opt_pact_shape
=
{
"nearest_interp_v2_26.tmp_0"
:[
1
,
256
,
160
,
160
],
"nearest_interp_v2_27.tmp_0"
:[
1
,
64
,
160
,
160
],
"nearest_interp_v2_28.tmp_0"
:[
1
,
64
,
160
,
160
],
"nearest_interp_v2_29.tmp_0"
:[
1
,
64
,
160
,
160
]
}
min_input_shape
.
update
(
min_pact_shape
)
max_input_shape
.
update
(
max_pact_shape
)
opt_input_shape
.
update
(
opt_pact_shape
)
elif
mode
==
"rec"
:
min_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
10
]}
max_input_shape
=
{
"x"
:
[
args
.
rec_batch_num
,
3
,
32
,
2000
]}
...
...
Prev
1
2
3
Next
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