Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
e807901b
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e807901b
编写于
5月 15, 2020
作者:
D
dyning
提交者:
GitHub
5月 15, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #39 from LDOUBLEV/fixocr
Fixocr
上级
b642f40e
1e9683b4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
13 addition
and
18 deletion
+13
-18
tools/infer/predict_det.py
tools/infer/predict_det.py
+9
-12
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+0
-1
tools/infer/utility.py
tools/infer/utility.py
+2
-3
tools/program.py
tools/program.py
+2
-2
未找到文件。
tools/infer/predict_det.py
浏览文件 @
e807901b
...
@@ -142,8 +142,8 @@ class TextDetector(object):
...
@@ -142,8 +142,8 @@ class TextDetector(object):
outputs
.
append
(
output
)
outputs
.
append
(
output
)
outs_dict
=
{}
outs_dict
=
{}
if
self
.
det_algorithm
==
"EAST"
:
if
self
.
det_algorithm
==
"EAST"
:
outs_dict
[
'f_
score
'
]
=
outputs
[
0
]
outs_dict
[
'f_
geo
'
]
=
outputs
[
0
]
outs_dict
[
'f_
geo
'
]
=
outputs
[
1
]
outs_dict
[
'f_
score
'
]
=
outputs
[
1
]
else
:
else
:
outs_dict
[
'maps'
]
=
outputs
[
0
]
outs_dict
[
'maps'
]
=
outputs
[
0
]
dt_boxes_list
=
self
.
postprocess_op
(
outs_dict
,
[
ratio_list
])
dt_boxes_list
=
self
.
postprocess_op
(
outs_dict
,
[
ratio_list
])
...
@@ -153,6 +153,8 @@ class TextDetector(object):
...
@@ -153,6 +153,8 @@ class TextDetector(object):
return
dt_boxes
,
elapse
return
dt_boxes
,
elapse
from
tools.infer.utility
import
draw_text_det_res
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
args
=
utility
.
parse_args
()
args
=
utility
.
parse_args
()
image_file_list
=
get_image_file_list
(
args
.
image_dir
)
image_file_list
=
get_image_file_list
(
args
.
image_dir
)
...
@@ -169,14 +171,9 @@ if __name__ == "__main__":
...
@@ -169,14 +171,9 @@ if __name__ == "__main__":
total_time
+=
elapse
total_time
+=
elapse
count
+=
1
count
+=
1
print
(
"Predict time of %s:"
%
image_file
,
elapse
)
print
(
"Predict time of %s:"
%
image_file
,
elapse
)
img
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
)
img_draw
=
draw_text_det_res
(
dt_boxes
,
image_file
,
return_img
=
True
)
draw_img
=
draw_ocr
(
img
,
dt_boxes
,
None
,
None
,
False
)
save_path
=
os
.
path
.
join
(
"./inference_det/"
,
draw_img_save
=
"./inference_results/"
os
.
path
.
basename
(
image_file
))
if
not
os
.
path
.
exists
(
draw_img_save
):
print
(
"The visualized image saved in {}"
.
format
(
save_path
))
os
.
makedirs
(
draw_img_save
)
cv2
.
imwrite
(
os
.
path
.
join
(
draw_img_save
,
os
.
path
.
basename
(
image_file
)),
draw_img
[:,
:,
::
-
1
])
print
(
"The visualized image saved in {}"
.
format
(
os
.
path
.
join
(
draw_img_save
,
os
.
path
.
basename
(
image_file
))))
print
(
"Avg Time:"
,
total_time
/
(
count
-
1
))
print
(
"Avg Time:"
,
total_time
/
(
count
-
1
))
tools/infer/predict_rec.py
浏览文件 @
e807901b
...
@@ -114,7 +114,6 @@ if __name__ == "__main__":
...
@@ -114,7 +114,6 @@ if __name__ == "__main__":
valid_image_file_list
.
append
(
image_file
)
valid_image_file_list
.
append
(
image_file
)
img_list
.
append
(
img
)
img_list
.
append
(
img
)
rec_res
,
predict_time
=
text_recognizer
(
img_list
)
rec_res
,
predict_time
=
text_recognizer
(
img_list
)
rec_res
,
predict_time
=
text_recognizer
(
img_list
)
for
ino
in
range
(
len
(
img_list
)):
for
ino
in
range
(
len
(
img_list
)):
print
(
"Predicts of %s:%s"
%
(
valid_image_file_list
[
ino
],
rec_res
[
ino
]))
print
(
"Predicts of %s:%s"
%
(
valid_image_file_list
[
ino
],
rec_res
[
ino
]))
print
(
"Total predict time for %d images:%.3f"
%
print
(
"Total predict time for %d images:%.3f"
%
...
...
tools/infer/utility.py
浏览文件 @
e807901b
...
@@ -103,13 +103,12 @@ def create_predictor(args, mode):
...
@@ -103,13 +103,12 @@ def create_predictor(args, mode):
return
predictor
,
input_tensor
,
output_tensors
return
predictor
,
input_tensor
,
output_tensors
def
draw_text_det_res
(
dt_boxes
,
img_path
):
def
draw_text_det_res
(
dt_boxes
,
img_path
,
return_img
=
True
):
src_im
=
cv2
.
imread
(
img_path
)
src_im
=
cv2
.
imread
(
img_path
)
for
box
in
dt_boxes
:
for
box
in
dt_boxes
:
box
=
np
.
array
(
box
).
astype
(
np
.
int32
).
reshape
(
-
1
,
2
)
box
=
np
.
array
(
box
).
astype
(
np
.
int32
).
reshape
(
-
1
,
2
)
cv2
.
polylines
(
src_im
,
[
box
],
True
,
color
=
(
255
,
255
,
0
),
thickness
=
2
)
cv2
.
polylines
(
src_im
,
[
box
],
True
,
color
=
(
255
,
255
,
0
),
thickness
=
2
)
img_name_pure
=
img_path
.
split
(
"/"
)[
-
1
]
return
src_im
cv2
.
imwrite
(
"./output/%s"
%
img_name_pure
,
src_im
)
def
resize_img
(
img
,
input_size
=
600
):
def
resize_img
(
img
,
input_size
=
600
):
...
...
tools/program.py
浏览文件 @
e807901b
...
@@ -191,8 +191,8 @@ def build_export(config, main_prog, startup_prog):
...
@@ -191,8 +191,8 @@ def build_export(config, main_prog, startup_prog):
func_infor
=
config
[
'Architecture'
][
'function'
]
func_infor
=
config
[
'Architecture'
][
'function'
]
model
=
create_module
(
func_infor
)(
params
=
config
)
model
=
create_module
(
func_infor
)(
params
=
config
)
image
,
outputs
=
model
(
mode
=
'export'
)
image
,
outputs
=
model
(
mode
=
'export'
)
fetches_var
=
[
outputs
[
name
]
for
name
in
outputs
]
fetches_var
=
sorted
([
outputs
[
name
]
for
name
in
outputs
])
fetches_var_name
=
[
name
for
name
in
outputs
]
fetches_var_name
=
[
name
for
name
in
fetches_var
]
feeded_var_names
=
[
image
.
name
]
feeded_var_names
=
[
image
.
name
]
target_vars
=
fetches_var
target_vars
=
fetches_var
return
feeded_var_names
,
target_vars
,
fetches_var_name
return
feeded_var_names
,
target_vars
,
fetches_var_name
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录