Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleOCR
提交
119d6663
P
PaddleOCR
项目概览
s920243400
/
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看板
未验证
提交
119d6663
编写于
4月 01, 2022
作者:
M
MissPenguin
提交者:
GitHub
4月 01, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5774 from LDOUBLEV/release/2.4
add end2end
上级
e0a52ee5
bc9fc148
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
44 addition
and
28 deletion
+44
-28
ppocr/losses/kie_sdmgr_loss.py
ppocr/losses/kie_sdmgr_loss.py
+1
-13
ppocr/modeling/heads/kie_sdmgr_head.py
ppocr/modeling/heads/kie_sdmgr_head.py
+1
-14
tools/infer/predict_system.py
tools/infer/predict_system.py
+41
-1
tools/infer/utility.py
tools/infer/utility.py
+1
-0
未找到文件。
ppocr/losses/kie_sdmgr_loss.py
浏览文件 @
119d6663
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Reference From: https://github.com/open-mmlab/mmocr/blob/main/mmocr/models/kie/losses/sdmgr_loss.py
from
__future__
import
absolute_import
from
__future__
import
division
...
...
ppocr/modeling/heads/kie_sdmgr_head.py
浏览文件 @
119d6663
# copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# reference from: https://github.com/open-mmlab/mmocr/blob/main/mmocr/models/kie/heads/sdmgr_head.py
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
...
...
tools/infer/predict_system.py
浏览文件 @
119d6663
...
...
@@ -27,6 +27,7 @@ import numpy as np
import
time
import
logging
from
PIL
import
Image
import
json
import
tools.infer.utility
as
utility
import
tools.infer.predict_rec
as
predict_rec
import
tools.infer.predict_det
as
predict_det
...
...
@@ -121,11 +122,31 @@ def sorted_boxes(dt_boxes):
return
_boxes
def
save_results_to_txt
(
results
,
path
):
if
os
.
path
.
isdir
(
path
):
if
not
os
.
path
.
exists
(
path
):
os
.
makedirs
(
path
)
with
open
(
os
.
path
.
join
(
path
,
"results.txt"
),
'w'
)
as
f
:
f
.
writelines
(
results
)
f
.
close
()
logger
.
info
(
"The results will be saved in {}"
.
format
(
os
.
path
.
join
(
path
,
"results.txt"
)))
else
:
draw_img_save
=
os
.
path
.
dirname
(
path
)
if
not
os
.
path
.
exists
(
draw_img_save
):
os
.
makedirs
(
draw_img_save
)
with
open
(
path
,
'w'
)
as
f
:
f
.
writelines
(
results
)
f
.
close
()
logger
.
info
(
"The results will be saved in {}"
.
format
(
path
))
def
main
(
args
):
image_file_list
=
get_image_file_list
(
args
.
image_dir
)
image_file_list
=
image_file_list
[
args
.
process_id
::
args
.
total_process_num
]
text_sys
=
TextSystem
(
args
)
is_visualize
=
Tru
e
is_visualize
=
args
.
is_visualiz
e
font_path
=
args
.
vis_font_path
drop_score
=
args
.
drop_score
...
...
@@ -139,6 +160,7 @@ def main(args):
cpu_mem
,
gpu_mem
,
gpu_util
=
0
,
0
,
0
_st
=
time
.
time
()
count
=
0
save_res
=
[]
for
idx
,
image_file
in
enumerate
(
image_file_list
):
img
,
flag
=
check_and_read_gif
(
image_file
)
...
...
@@ -152,6 +174,21 @@ def main(args):
elapse
=
time
.
time
()
-
starttime
total_time
+=
elapse
# save results
preds
=
[]
dt_num
=
len
(
dt_boxes
)
for
dno
in
range
(
dt_num
):
text
,
score
=
rec_res
[
dno
]
if
score
>=
drop_score
:
preds
.
append
({
"transcription"
:
text
,
"points"
:
np
.
array
(
dt_boxes
[
dno
]).
tolist
()
})
text_str
=
"%s, %.3f"
%
(
text
,
score
)
save_res
.
append
(
image_file
+
'
\t
'
+
json
.
dumps
(
preds
,
ensure_ascii
=
False
)
+
'
\n
'
)
# print predicted results
logger
.
debug
(
str
(
idx
)
+
" Predict time of %s: %.3fs"
%
(
image_file
,
elapse
))
for
text
,
score
in
rec_res
:
...
...
@@ -180,6 +217,9 @@ def main(args):
logger
.
debug
(
"The visualized image saved in {}"
.
format
(
os
.
path
.
join
(
draw_img_save_dir
,
os
.
path
.
basename
(
image_file
))))
# The predicted results will be saved in os.path.join(os.draw_img_save_dir, "results.txt")
save_results_to_txt
(
save_res
,
args
.
draw_img_save_dir
)
logger
.
info
(
"The predict total time is {}"
.
format
(
time
.
time
()
-
_st
))
if
args
.
benchmark
:
text_sys
.
text_detector
.
autolog
.
report
()
...
...
tools/infer/utility.py
浏览文件 @
119d6663
...
...
@@ -114,6 +114,7 @@ def init_args():
#
parser
.
add_argument
(
"--draw_img_save_dir"
,
type
=
str
,
default
=
"./inference_results"
)
parser
.
add_argument
(
"--is_visualize"
,
type
=
str2bool
,
default
=
True
)
parser
.
add_argument
(
"--save_crop_res"
,
type
=
str2bool
,
default
=
False
)
parser
.
add_argument
(
"--crop_res_save_dir"
,
type
=
str
,
default
=
"./output"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录