Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
devil_zzz123
PaddleOCR
提交
89e031f0
P
PaddleOCR
项目概览
devil_zzz123
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
2
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89e031f0
编写于
11月 09, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加infer_det和infer_rec
上级
b28ea0a9
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
31 deletion
+13
-31
tools/infer_det.py
tools/infer_det.py
+7
-16
tools/infer_rec.py
tools/infer_rec.py
+6
-15
未找到文件。
tools/infer_det.py
浏览文件 @
89e031f0
...
@@ -29,12 +29,11 @@ import cv2
...
@@ -29,12 +29,11 @@ import cv2
import
json
import
json
import
paddle
import
paddle
from
ppocr.utils.logging
import
get_logger
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling
import
build_model
from
ppocr.modeling
.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init_model
from
ppocr.utils.save_load
import
init_model
from
ppocr.utils.utility
import
print_dict
,
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -67,11 +66,11 @@ def main():
...
@@ -67,11 +66,11 @@ def main():
# create data ops
# create data ops
transforms
=
[]
transforms
=
[]
for
op
in
config
[
'E
VAL
'
][
'dataset'
][
'transforms'
]:
for
op
in
config
[
'E
val
'
][
'dataset'
][
'transforms'
]:
op_name
=
list
(
op
)[
0
]
op_name
=
list
(
op
)[
0
]
if
'Label'
in
op_name
:
if
'Label'
in
op_name
:
continue
continue
elif
op_name
==
'
k
eepKeys'
:
elif
op_name
==
'
K
eepKeys'
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'shape'
]
op
[
op_name
][
'keep_keys'
]
=
[
'image'
,
'shape'
]
transforms
.
append
(
op
)
transforms
.
append
(
op
)
...
@@ -92,8 +91,7 @@ def main():
...
@@ -92,8 +91,7 @@ def main():
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
shape_list
=
np
.
expand_dims
(
batch
[
1
],
axis
=
0
)
shape_list
=
np
.
expand_dims
(
batch
[
1
],
axis
=
0
)
images
=
paddle
.
to_variable
(
images
)
images
=
paddle
.
to_tensor
(
images
)
print
(
images
.
shape
)
preds
=
model
(
images
)
preds
=
model
(
images
)
post_result
=
post_process_class
(
preds
,
shape_list
)
post_result
=
post_process_class
(
preds
,
shape_list
)
boxes
=
post_result
[
0
][
'points'
]
boxes
=
post_result
[
0
][
'points'
]
...
@@ -109,14 +107,7 @@ def main():
...
@@ -109,14 +107,7 @@ def main():
draw_det_res
(
boxes
,
config
,
src_img
,
file
)
draw_det_res
(
boxes
,
config
,
src_img
,
file
)
logger
.
info
(
"success!"
)
logger
.
info
(
"success!"
)
# save inference model
# paddle.jit.save(model, 'output/model')
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
place
,
config
=
program
.
preprocess
()
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
paddle
.
disable_static
(
place
)
logger
=
get_logger
()
print_dict
(
config
,
logger
)
main
()
main
()
\ No newline at end of file
tools/infer_rec.py
浏览文件 @
89e031f0
...
@@ -27,12 +27,11 @@ sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
...
@@ -27,12 +27,11 @@ sys.path.append(os.path.abspath(os.path.join(__dir__, '..')))
import
paddle
import
paddle
from
ppocr.utils.logging
import
get_logger
from
ppocr.data
import
create_operators
,
transform
from
ppocr.data
import
create_operators
,
transform
from
ppocr.modeling
import
build_model
from
ppocr.modeling
.architectures
import
build_model
from
ppocr.postprocess
import
build_post_process
from
ppocr.postprocess
import
build_post_process
from
ppocr.utils.save_load
import
init_model
from
ppocr.utils.save_load
import
init_model
from
ppocr.utils.utility
import
print_dict
,
get_image_file_list
from
ppocr.utils.utility
import
get_image_file_list
import
tools.program
as
program
import
tools.program
as
program
...
@@ -54,13 +53,13 @@ def main():
...
@@ -54,13 +53,13 @@ def main():
# create data ops
# create data ops
transforms
=
[]
transforms
=
[]
for
op
in
config
[
'E
VAL
'
][
'dataset'
][
'transforms'
]:
for
op
in
config
[
'E
val
'
][
'dataset'
][
'transforms'
]:
op_name
=
list
(
op
)[
0
]
op_name
=
list
(
op
)[
0
]
if
'Label'
in
op_name
:
if
'Label'
in
op_name
:
continue
continue
elif
op_name
in
[
'RecResizeImg'
]:
elif
op_name
in
[
'RecResizeImg'
]:
op
[
op_name
][
'infer_mode'
]
=
True
op
[
op_name
][
'infer_mode'
]
=
True
elif
op_name
==
'
k
eepKeys'
:
elif
op_name
==
'
K
eepKeys'
:
op
[
op_name
][
'keep_keys'
]
=
[
'image'
]
op
[
op_name
][
'keep_keys'
]
=
[
'image'
]
transforms
.
append
(
op
)
transforms
.
append
(
op
)
global_config
[
'infer_mode'
]
=
True
global_config
[
'infer_mode'
]
=
True
...
@@ -75,22 +74,14 @@ def main():
...
@@ -75,22 +74,14 @@ def main():
batch
=
transform
(
data
,
ops
)
batch
=
transform
(
data
,
ops
)
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
np
.
expand_dims
(
batch
[
0
],
axis
=
0
)
images
=
paddle
.
to_
variable
(
images
)
images
=
paddle
.
to_
tensor
(
images
)
preds
=
model
(
images
)
preds
=
model
(
images
)
post_result
=
post_process_class
(
preds
)
post_result
=
post_process_class
(
preds
)
for
rec_reuslt
in
post_result
:
for
rec_reuslt
in
post_result
:
logger
.
info
(
'
\t
result: {}'
.
format
(
rec_reuslt
))
logger
.
info
(
'
\t
result: {}'
.
format
(
rec_reuslt
))
logger
.
info
(
"success!"
)
logger
.
info
(
"success!"
)
# save inference model
# currently, paddle.jit.to_static not support rnn
# paddle.jit.save(model, 'output/rec/model')
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
place
,
config
=
program
.
preprocess
()
config
,
device
,
logger
,
vdl_writer
=
program
.
preprocess
()
paddle
.
disable_static
(
place
)
logger
=
get_logger
()
print_dict
(
config
,
logger
)
main
()
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录