Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
01fd2d0f
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看板
提交
01fd2d0f
编写于
2月 07, 2022
作者:
littletomatodonkey
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add system pred save
上级
aaae4958
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
5 deletion
+19
-5
tools/infer/predict_system.py
tools/infer/predict_system.py
+19
-5
未找到文件。
tools/infer/predict_system.py
浏览文件 @
01fd2d0f
...
@@ -24,6 +24,7 @@ os.environ["FLAGS_allocator_strategy"] = 'auto_growth'
...
@@ -24,6 +24,7 @@ os.environ["FLAGS_allocator_strategy"] = 'auto_growth'
import
cv2
import
cv2
import
copy
import
copy
import
numpy
as
np
import
numpy
as
np
import
json
import
time
import
time
import
logging
import
logging
from
PIL
import
Image
from
PIL
import
Image
...
@@ -92,11 +93,11 @@ class TextSystem(object):
...
@@ -92,11 +93,11 @@ class TextSystem(object):
self
.
draw_crop_rec_res
(
self
.
args
.
crop_res_save_dir
,
img_crop_list
,
self
.
draw_crop_rec_res
(
self
.
args
.
crop_res_save_dir
,
img_crop_list
,
rec_res
)
rec_res
)
filter_boxes
,
filter_rec_res
=
[],
[]
filter_boxes
,
filter_rec_res
=
[],
[]
for
box
,
rec_re
su
lt
in
zip
(
dt_boxes
,
rec_res
):
for
box
,
rec_re
us
lt
in
zip
(
dt_boxes
,
rec_res
):
text
,
score
=
rec_re
su
lt
text
,
score
=
rec_re
us
lt
if
score
>=
self
.
drop_score
:
if
score
>=
self
.
drop_score
:
filter_boxes
.
append
(
box
)
filter_boxes
.
append
(
box
)
filter_rec_res
.
append
(
rec_re
su
lt
)
filter_rec_res
.
append
(
rec_re
us
lt
)
return
filter_boxes
,
filter_rec_res
return
filter_boxes
,
filter_rec_res
...
@@ -128,6 +129,9 @@ def main(args):
...
@@ -128,6 +129,9 @@ def main(args):
is_visualize
=
True
is_visualize
=
True
font_path
=
args
.
vis_font_path
font_path
=
args
.
vis_font_path
drop_score
=
args
.
drop_score
drop_score
=
args
.
drop_score
draw_img_save_dir
=
args
.
draw_img_save_dir
os
.
makedirs
(
draw_img_save_dir
,
exist_ok
=
True
)
save_results
=
[]
# warm up 10 times
# warm up 10 times
if
args
.
warmup
:
if
args
.
warmup
:
...
@@ -157,6 +161,14 @@ def main(args):
...
@@ -157,6 +161,14 @@ def main(args):
for
text
,
score
in
rec_res
:
for
text
,
score
in
rec_res
:
logger
.
debug
(
"{}, {:.3f}"
.
format
(
text
,
score
))
logger
.
debug
(
"{}, {:.3f}"
.
format
(
text
,
score
))
res
=
[{
"transcription"
:
rec_res
[
idx
][
0
],
"points"
:
np
.
array
(
dt_boxes
[
idx
]).
astype
(
np
.
int32
).
tolist
(),
}
for
idx
in
range
(
len
(
dt_boxes
))
if
rec_res
[
idx
][
1
]
>=
drop_score
]
save_pred
=
os
.
path
.
basename
(
image_file
)
+
"
\t
"
+
json
.
dumps
(
res
,
ensure_ascii
=
False
)
+
"
\n
"
save_results
.
append
(
save_pred
)
if
is_visualize
:
if
is_visualize
:
image
=
Image
.
fromarray
(
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
))
image
=
Image
.
fromarray
(
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2RGB
))
boxes
=
dt_boxes
boxes
=
dt_boxes
...
@@ -170,8 +182,6 @@ def main(args):
...
@@ -170,8 +182,6 @@ def main(args):
scores
,
scores
,
drop_score
=
drop_score
,
drop_score
=
drop_score
,
font_path
=
font_path
)
font_path
=
font_path
)
draw_img_save_dir
=
args
.
draw_img_save_dir
os
.
makedirs
(
draw_img_save_dir
,
exist_ok
=
True
)
if
flag
:
if
flag
:
image_file
=
image_file
[:
-
3
]
+
"png"
image_file
=
image_file
[:
-
3
]
+
"png"
cv2
.
imwrite
(
cv2
.
imwrite
(
...
@@ -185,6 +195,10 @@ def main(args):
...
@@ -185,6 +195,10 @@ def main(args):
text_sys
.
text_detector
.
autolog
.
report
()
text_sys
.
text_detector
.
autolog
.
report
()
text_sys
.
text_recognizer
.
autolog
.
report
()
text_sys
.
text_recognizer
.
autolog
.
report
()
with
open
(
os
.
path
.
join
(
draw_img_save_dir
,
"system_results.txt"
),
'w'
)
as
f
:
f
.
writelines
(
save_results
)
f
.
close
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
args
=
utility
.
parse_args
()
args
=
utility
.
parse_args
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录