Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
f2c4d669
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1525
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f2c4d669
编写于
7月 01, 2020
作者:
D
Double_V
提交者:
GitHub
7月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #279 from LDOUBLEV/fixocr
fix Nan results and add test_reader func
上级
cc49cb90
6f456775
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
1 deletion
+25
-1
tools/infer/predict_rec.py
tools/infer/predict_rec.py
+2
-0
tools/infer_rec.py
tools/infer_rec.py
+2
-0
tools/train.py
tools/train.py
+21
-1
未找到文件。
tools/infer/predict_rec.py
浏览文件 @
f2c4d669
...
@@ -122,6 +122,8 @@ class TextRecognizer(object):
...
@@ -122,6 +122,8 @@ class TextRecognizer(object):
blank
=
probs
.
shape
[
1
]
blank
=
probs
.
shape
[
1
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
if
len
(
valid_ind
)
==
0
:
continue
# rec_res.append([preds_text, score])
# rec_res.append([preds_text, score])
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
[
preds_text
,
score
]
rec_res
[
indices
[
beg_img_no
+
rno
]]
=
[
preds_text
,
score
]
else
:
else
:
...
...
tools/infer_rec.py
浏览文件 @
f2c4d669
...
@@ -99,6 +99,8 @@ def main():
...
@@ -99,6 +99,8 @@ def main():
ind
=
np
.
argmax
(
probs
,
axis
=
1
)
ind
=
np
.
argmax
(
probs
,
axis
=
1
)
blank
=
probs
.
shape
[
1
]
blank
=
probs
.
shape
[
1
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
valid_ind
=
np
.
where
(
ind
!=
(
blank
-
1
))[
0
]
if
len
(
valid_ind
)
==
0
:
continue
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
score
=
np
.
mean
(
probs
[
valid_ind
,
ind
[
valid_ind
]])
elif
loss_type
==
"attention"
:
elif
loss_type
==
"attention"
:
preds
=
np
.
array
(
predict
[
0
])
preds
=
np
.
array
(
predict
[
0
])
...
...
tools/train.py
浏览文件 @
f2c4d669
...
@@ -36,7 +36,7 @@ set_paddle_flags(
...
@@ -36,7 +36,7 @@ set_paddle_flags(
FLAGS_eager_delete_tensor_gb
=
0
,
# enable GC to save memory
FLAGS_eager_delete_tensor_gb
=
0
,
# enable GC to save memory
)
)
import
program
import
tools.program
as
program
from
paddle
import
fluid
from
paddle
import
fluid
from
ppocr.utils.utility
import
initial_logger
from
ppocr.utils.utility
import
initial_logger
logger
=
initial_logger
()
logger
=
initial_logger
()
...
@@ -106,6 +106,26 @@ def main():
...
@@ -106,6 +106,26 @@ def main():
program
.
train_eval_rec_run
(
config
,
exe
,
train_info_dict
,
eval_info_dict
)
program
.
train_eval_rec_run
(
config
,
exe
,
train_info_dict
,
eval_info_dict
)
def
test_reader
():
config
=
program
.
load_config
(
FLAGS
.
config
)
program
.
merge_config
(
FLAGS
.
opt
)
print
(
config
)
train_reader
=
reader_main
(
config
=
config
,
mode
=
"train"
)
import
time
starttime
=
time
.
time
()
count
=
0
try
:
for
data
in
train_reader
():
count
+=
1
if
count
%
1
==
0
:
batch_time
=
time
.
time
()
-
starttime
starttime
=
time
.
time
()
print
(
"reader:"
,
count
,
len
(
data
),
batch_time
)
except
Exception
as
e
:
logger
.
info
(
e
)
logger
.
info
(
"finish reader: {}, Success!"
.
format
(
count
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
parser
=
program
.
ArgsParser
()
parser
=
program
.
ArgsParser
()
FLAGS
=
parser
.
parse_args
()
FLAGS
=
parser
.
parse_args
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录