Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
0c287c41
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看板
提交
0c287c41
编写于
11月 17, 2020
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
python端预测完成
上级
903b102f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
21 deletion
+20
-21
tools/infer/predict_cls.py
tools/infer/predict_cls.py
+2
-1
tools/infer/predict_det.py
tools/infer/predict_det.py
+2
-2
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+7
-4
tools/infer/predict_system.py
tools/infer/predict_system.py
+7
-13
tools/infer/utility.py
tools/infer/utility.py
+2
-1
未找到文件。
tools/infer/predict_cls.py
浏览文件 @
0c287c41
...
...
@@ -31,6 +31,8 @@ from ppocr.postprocess import build_post_process
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils.utility
import
get_image_file_list
,
check_and_read_gif
logger
=
get_logger
()
class
TextClassifier
(
object
):
def
__init__
(
self
,
args
):
...
...
@@ -147,5 +149,4 @@ def main(args):
if
__name__
==
"__main__"
:
logger
=
get_logger
()
main
(
utility
.
parse_args
())
tools/infer/predict_det.py
浏览文件 @
0c287c41
...
...
@@ -30,6 +30,8 @@ from ppocr.utils.utility import get_image_file_list, check_and_read_gif
from
ppocr.data
import
create_operators
,
transform
from
ppocr.postprocess
import
build_post_process
logger
=
get_logger
()
class
TextDetector
(
object
):
def
__init__
(
self
,
args
):
...
...
@@ -158,9 +160,7 @@ class TextDetector(object):
if
__name__
==
"__main__"
:
args
=
utility
.
parse_args
()
image_file_list
=
get_image_file_list
(
args
.
image_dir
)
logger
=
get_logger
()
text_detector
=
TextDetector
(
args
)
count
=
0
total_time
=
0
...
...
tools/infer/predict_rec.py
浏览文件 @
0c287c41
...
...
@@ -13,12 +13,12 @@
# limitations under the License.
import
os
import
sys
__dir__
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'../..'
)))
import
cv2
import
copy
import
numpy
as
np
import
math
import
time
...
...
@@ -30,6 +30,8 @@ from ppocr.postprocess import build_post_process
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils.utility
import
get_image_file_list
,
check_and_read_gif
logger
=
get_logger
()
class
TextRecognizer
(
object
):
def
__init__
(
self
,
args
):
...
...
@@ -80,7 +82,7 @@ class TextRecognizer(object):
# rec_res = []
rec_res
=
[[
''
,
0.0
]]
*
img_num
batch_num
=
self
.
rec_batch_num
predict_tim
e
=
0
elaps
e
=
0
for
beg_img_no
in
range
(
0
,
img_num
,
batch_num
):
end_img_no
=
min
(
img_num
,
beg_img_no
+
batch_num
)
norm_img_batch
=
[]
...
...
@@ -110,7 +112,9 @@ class TextRecognizer(object):
output
=
output_tensor
.
copy_to_cpu
()
outputs
.
append
(
output
)
preds
=
outputs
[
0
]
rec_res
=
self
.
postprocess_op
(
preds
)
rec_result
=
self
.
postprocess_op
(
preds
)
for
rno
in
range
(
len
(
rec_result
)):
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
rec_result
[
rno
]
elapse
=
time
.
time
()
-
starttime
return
rec_res
,
elapse
...
...
@@ -147,5 +151,4 @@ def main(args):
if
__name__
==
"__main__"
:
logger
=
get_logger
()
main
(
utility
.
parse_args
())
tools/infer/predict_system.py
浏览文件 @
0c287c41
...
...
@@ -17,20 +17,17 @@ __dir__ = os.path.dirname(os.path.abspath(__file__))
sys
.
path
.
append
(
__dir__
)
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
__dir__
,
'../..'
)))
import
tools.infer.utility
as
utility
from
ppocr.utils.utility
import
initial_logger
logger
=
initial_logger
()
import
cv2
import
tools.infer.predict_det
as
predict_det
import
tools.infer.predict_rec
as
predict_rec
import
copy
import
numpy
as
np
import
math
import
time
from
ppocr.utils.utility
import
get_image_file_list
,
check_and_read_gif
from
PIL
import
Image
import
tools.infer.utility
as
utility
from
tools.infer.utility
import
draw_ocr
from
tools.infer.utility
import
draw_ocr_box_txt
import
tools.infer.predict_rec
as
predict_rec
import
tools.infer.predict_det
as
predict_det
from
ppocr.utils.utility
import
get_image_file_list
,
check_and_read_gif
from
ppocr.utils.logging
import
get_logger
class
TextSystem
(
object
):
...
...
@@ -153,11 +150,7 @@ def main(args):
scores
=
[
rec_res
[
i
][
1
]
for
i
in
range
(
len
(
rec_res
))]
draw_img
=
draw_ocr
(
image
,
boxes
,
txts
,
scores
,
drop_score
=
drop_score
)
image
,
boxes
,
txts
,
scores
,
drop_score
=
drop_score
)
draw_img_save
=
"./inference_results/"
if
not
os
.
path
.
exists
(
draw_img_save
):
os
.
makedirs
(
draw_img_save
)
...
...
@@ -169,4 +162,5 @@ def main(args):
if
__name__
==
"__main__"
:
logger
=
get_logger
()
main
(
utility
.
parse_args
())
tools/infer/utility.py
浏览文件 @
0c287c41
...
...
@@ -39,7 +39,8 @@ def parse_args():
parser
.
add_argument
(
"--image_dir"
,
type
=
str
)
parser
.
add_argument
(
"--det_algorithm"
,
type
=
str
,
default
=
'DB'
)
parser
.
add_argument
(
"--det_model_dir"
,
type
=
str
)
parser
.
add_argument
(
"--det_max_side_len"
,
type
=
float
,
default
=
960
)
parser
.
add_argument
(
"--det_limit_side_len"
,
type
=
float
,
default
=
960
)
parser
.
add_argument
(
"--det_limit_type"
,
type
=
str
,
default
=
'max'
)
# DB parmas
parser
.
add_argument
(
"--det_db_thresh"
,
type
=
float
,
default
=
0.3
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录