Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
f15d7ff3
M
models
项目概览
PaddlePaddle
/
models
1 年多 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f15d7ff3
编写于
8月 14, 2018
作者:
W
whs
提交者:
GitHub
8月 14, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ce of ocr. (#1133)
* Fix ce of ocr. * Remove debug print
上级
b8e6805d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
16 deletion
+27
-16
fluid/ocr_recognition/.run_ce.sh
fluid/ocr_recognition/.run_ce.sh
+5
-1
fluid/ocr_recognition/ctc_reader.py
fluid/ocr_recognition/ctc_reader.py
+18
-14
fluid/ocr_recognition/ctc_train.py
fluid/ocr_recognition/ctc_train.py
+4
-1
未找到文件。
fluid/ocr_recognition/.run_ce.sh
浏览文件 @
f15d7ff3
python ctc_train.py
--batch_size
=
128
--total_step
=
10000
-eval_period
=
10000
--log_period
=
10000
--use_gpu
=
True | python _ce.py
export
ce_mode
=
1
rm
*
factor.txt
python ctc_train.py
--batch_size
=
32
--total_step
=
30000
--eval_period
=
30000
--log_period
=
30000
--use_gpu
=
True 1> ./tmp.log
cat
tmp.log | python _ce.py
rm
tmp.log
fluid/ocr_recognition/ctc_reader.py
浏览文件 @
f15d7ff3
...
...
@@ -25,7 +25,12 @@ class DataGenerator(object):
def
__init__
(
self
):
pass
def
train_reader
(
self
,
img_root_dir
,
img_label_list
,
batchsize
,
cycle
):
def
train_reader
(
self
,
img_root_dir
,
img_label_list
,
batchsize
,
cycle
,
shuffle
=
True
):
'''
Reader interface for training.
...
...
@@ -42,15 +47,12 @@ class DataGenerator(object):
'''
img_label_lines
=
[]
if
batchsize
==
1
:
to_file
=
"tmp.txt"
to_file
=
"tmp.txt"
if
not
shuffle
:
cmd
=
"cat "
+
img_label_list
+
" | awk '{print $1,$2,$3,$4;}' > "
+
to_file
elif
batchsize
==
1
:
cmd
=
"cat "
+
img_label_list
+
" | awk '{print $1,$2,$3,$4;}' | shuf > "
+
to_file
print
"cmd: "
+
cmd
os
.
system
(
cmd
)
print
"finish batch shuffle"
img_label_lines
=
open
(
to_file
,
'r'
).
readlines
()
else
:
to_file
=
"tmp.txt"
#cmd1: partial shuffle
cmd
=
"cat "
+
img_label_list
+
" | awk '{printf(
\"
%04d%.4f %s
\\
n
\"
, $1, rand(), $0)}' | sort | sed 1,$((1 + RANDOM % 100))d | "
#cmd2: batch merge and shuffle
...
...
@@ -62,10 +64,9 @@ class DataGenerator(object):
)
+
" * 4) {for(i = 0; i < "
+
str
(
batchsize
)
+
"; i++) print $(4*i+1)
\"
\"
$(4*i+2)
\"
\"
$(4*i+3)
\"
\"
$(4*i+4);}}' > "
+
to_file
print
"cmd: "
+
cmd
os
.
system
(
cmd
)
print
"finish batch shuffle"
img_label_lines
=
open
(
to_file
,
'r'
).
readlines
()
os
.
system
(
cmd
)
print
"finish batch shuffle"
img_label_lines
=
open
(
to_file
,
'r'
).
readlines
()
def
reader
():
sizes
=
len
(
img_label_lines
)
/
batchsize
...
...
@@ -191,8 +192,11 @@ def train(batch_size, train_images_dir=None, train_list_file=None, cycle=False):
train_images_dir
=
path
.
join
(
data_dir
,
TRAIN_DATA_DIR_NAME
)
if
train_list_file
is
None
:
train_list_file
=
path
.
join
(
data_dir
,
TRAIN_LIST_FILE_NAME
)
return
generator
.
train_reader
(
train_images_dir
,
train_list_file
,
batch_size
,
cycle
)
shuffle
=
True
if
'ce_mode'
in
os
.
environ
:
shuffle
=
False
return
generator
.
train_reader
(
train_images_dir
,
train_list_file
,
batch_size
,
cycle
,
shuffle
=
shuffle
)
def
test
(
batch_size
=
1
,
test_images_dir
=
None
,
test_list_file
=
None
):
...
...
fluid/ocr_recognition/ctc_train.py
浏览文件 @
f15d7ff3
...
...
@@ -63,6 +63,10 @@ def train(args, data_reader=ctc_reader):
if
args
.
use_gpu
:
place
=
fluid
.
CUDAPlace
(
0
)
exe
=
fluid
.
Executor
(
place
)
if
'ce_mode'
in
os
.
environ
:
fluid
.
default_startup_program
().
random_seed
=
90
exe
.
run
(
fluid
.
default_startup_program
())
# load init model
...
...
@@ -148,7 +152,6 @@ def train(args, data_reader=ctc_reader):
args
.
batch_size
))
print
"kpis train_acc %f"
%
(
1
-
total_seq_error
/
(
args
.
log_period
*
args
.
batch_size
))
sys
.
stdout
.
flush
()
total_loss
=
0.0
total_seq_error
=
0.0
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录