Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
aa7e9ac3
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看板
提交
aa7e9ac3
编写于
9月 03, 2020
作者:
T
tink2123
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish code
上级
bc1ad207
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
35 addition
and
36 deletion
+35
-36
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+30
-26
tools/infer/utility.py
tools/infer/utility.py
+4
-6
tools/infer_rec.py
tools/infer_rec.py
+1
-4
未找到文件。
tools/infer/predict_rec.py
浏览文件 @
aa7e9ac3
...
@@ -196,15 +196,15 @@ class TextRecognizer(object):
...
@@ -196,15 +196,15 @@ class TextRecognizer(object):
norm_img_batch
.
append
(
norm_img
[
0
])
norm_img_batch
.
append
(
norm_img
[
0
])
norm_img_batch
=
np
.
concatenate
(
norm_img_batch
,
axis
=
0
)
norm_img_batch
=
np
.
concatenate
(
norm_img_batch
,
axis
=
0
)
norm_img_batch
=
norm_img_batch
.
copy
()
if
self
.
loss_type
==
"srn"
:
encoder_word_pos_list
=
np
.
concatenate
(
encoder_word_pos_list
)
encoder_word_pos_list
=
np
.
concatenate
(
encoder_word_pos_list
)
gsrm_word_pos_list
=
np
.
concatenate
(
gsrm_word_pos_list
)
gsrm_word_pos_list
=
np
.
concatenate
(
gsrm_word_pos_list
)
gsrm_slf_attn_bias1_list
=
np
.
concatenate
(
gsrm_slf_attn_bias1_list
=
np
.
concatenate
(
gsrm_slf_attn_bias1_list
)
gsrm_slf_attn_bias1_list
)
gsrm_slf_attn_bias2_list
=
np
.
concatenate
(
gsrm_slf_attn_bias2_list
=
np
.
concatenate
(
gsrm_slf_attn_bias2_list
)
gsrm_slf_attn_bias2_list
)
starttime
=
time
.
time
()
starttime
=
time
.
time
()
norm_img_batch
=
fluid
.
core
.
PaddleTensor
(
norm_img_batch
)
norm_img_batch
=
fluid
.
core
.
PaddleTensor
(
norm_img_batch
)
...
@@ -217,11 +217,15 @@ class TextRecognizer(object):
...
@@ -217,11 +217,15 @@ class TextRecognizer(object):
gsrm_slf_attn_bias2_list
)
gsrm_slf_attn_bias2_list
)
inputs
=
[
inputs
=
[
norm_img_batch
,
encoder_word_pos_list
,
gsrm_slf_attn_bias1_list
,
norm_img_batch
,
encoder_word_pos_list
,
gsrm_slf_attn_bias2_list
,
gsrm_word_pos_list
gsrm_slf_attn_bias1_list
,
gsrm_slf_attn_bias2_list
,
gsrm_word_pos_list
]
]
self
.
predictor
.
run
(
inputs
)
self
.
predictor
.
run
(
inputs
)
else
:
self
.
input_tensor
.
copy_from_cpu
(
norm_img_batch
)
self
.
predictor
.
zero_copy_run
()
if
self
.
loss_type
==
"ctc"
:
if
self
.
loss_type
==
"ctc"
:
rec_idx_batch
=
self
.
output_tensors
[
0
].
copy_to_cpu
()
rec_idx_batch
=
self
.
output_tensors
[
0
].
copy_to_cpu
()
...
...
tools/infer/utility.py
浏览文件 @
aa7e9ac3
...
@@ -59,10 +59,10 @@ def parse_args():
...
@@ -59,10 +59,10 @@ def parse_args():
parser
.
add_argument
(
"--det_sast_polygon"
,
type
=
bool
,
default
=
False
)
parser
.
add_argument
(
"--det_sast_polygon"
,
type
=
bool
,
default
=
False
)
#params for text recognizer
#params for text recognizer
parser
.
add_argument
(
"--rec_algorithm"
,
type
=
str
,
default
=
'
SR
N'
)
parser
.
add_argument
(
"--rec_algorithm"
,
type
=
str
,
default
=
'
CRN
N'
)
parser
.
add_argument
(
"--rec_model_dir"
,
type
=
str
)
parser
.
add_argument
(
"--rec_model_dir"
,
type
=
str
)
parser
.
add_argument
(
"--rec_image_shape"
,
type
=
str
,
default
=
"3,
64, 256
"
)
parser
.
add_argument
(
"--rec_image_shape"
,
type
=
str
,
default
=
"3,
32, 320
"
)
parser
.
add_argument
(
"--rec_char_type"
,
type
=
str
,
default
=
'
en
'
)
parser
.
add_argument
(
"--rec_char_type"
,
type
=
str
,
default
=
'
ch
'
)
parser
.
add_argument
(
"--rec_batch_num"
,
type
=
int
,
default
=
30
)
parser
.
add_argument
(
"--rec_batch_num"
,
type
=
int
,
default
=
30
)
parser
.
add_argument
(
"--max_text_length"
,
type
=
int
,
default
=
25
)
parser
.
add_argument
(
"--max_text_length"
,
type
=
int
,
default
=
25
)
parser
.
add_argument
(
parser
.
add_argument
(
...
@@ -107,11 +107,9 @@ def create_predictor(args, mode):
...
@@ -107,11 +107,9 @@ def create_predictor(args, mode):
# use zero copy
# use zero copy
config
.
delete_pass
(
"conv_transpose_eltwiseadd_bn_fuse_pass"
)
config
.
delete_pass
(
"conv_transpose_eltwiseadd_bn_fuse_pass"
)
#config.switch_use_feed_fetch_ops(False)
config
.
switch_use_feed_fetch_ops
(
False
)
config
.
switch_use_feed_fetch_ops
(
True
)
predictor
=
create_paddle_predictor
(
config
)
predictor
=
create_paddle_predictor
(
config
)
input_names
=
predictor
.
get_input_names
()
input_names
=
predictor
.
get_input_names
()
print
(
input_names
)
for
name
in
input_names
:
for
name
in
input_names
:
input_tensor
=
predictor
.
get_input_tensor
(
name
)
input_tensor
=
predictor
.
get_input_tensor
(
name
)
output_names
=
predictor
.
get_output_names
()
output_names
=
predictor
.
get_output_names
()
...
...
tools/infer_rec.py
浏览文件 @
aa7e9ac3
...
@@ -162,10 +162,7 @@ def main():
...
@@ -162,10 +162,7 @@ def main():
fluid
.
io
.
save_inference_model
(
fluid
.
io
.
save_inference_model
(
"./output/"
,
"./output/"
,
feeded_var_names
=
[
feeded_var_names
=
[
'image'
],
'image'
,
'encoder_word_pos'
,
'gsrm_slf_attn_bias1'
,
'gsrm_slf_attn_bias2'
,
'gsrm_word_pos'
],
target_vars
=
target_var
,
target_vars
=
target_var
,
executor
=
exe
,
executor
=
exe
,
main_program
=
eval_prog
,
main_program
=
eval_prog
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录