Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
57fd89dc
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看板
未验证
提交
57fd89dc
编写于
7月 18, 2019
作者:
W
whs
提交者:
GitHub
7月 18, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Check use_gpu in ocr models. (#2736)
上级
23d450e9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
34 addition
and
7 deletion
+34
-7
PaddleCV/ocr_recognition/eval.py
PaddleCV/ocr_recognition/eval.py
+2
-0
PaddleCV/ocr_recognition/infer.py
PaddleCV/ocr_recognition/infer.py
+2
-0
PaddleCV/ocr_recognition/train.py
PaddleCV/ocr_recognition/train.py
+11
-7
PaddleCV/ocr_recognition/utility.py
PaddleCV/ocr_recognition/utility.py
+19
-0
未找到文件。
PaddleCV/ocr_recognition/eval.py
浏览文件 @
57fd89dc
import
paddle.fluid
as
fluid
from
utility
import
add_arguments
,
print_arguments
,
to_lodtensor
,
get_ctc_feeder_data
,
get_attention_feeder_data
from
utility
import
check_gpu
from
attention_model
import
attention_eval
from
crnn_ctc_model
import
ctc_eval
import
data_reader
...
...
@@ -70,6 +71,7 @@ def evaluate(args):
def
main
():
args
=
parser
.
parse_args
()
print_arguments
(
args
)
check_gpu
(
args
.
use_gpu
)
evaluate
(
args
)
...
...
PaddleCV/ocr_recognition/infer.py
浏览文件 @
57fd89dc
from
__future__
import
print_function
import
paddle.fluid
as
fluid
from
utility
import
add_arguments
,
print_arguments
,
to_lodtensor
,
get_ctc_feeder_data
,
get_attention_feeder_for_infer
,
get_ctc_feeder_for_infer
from
utility
import
check_gpu
import
paddle.fluid.profiler
as
profiler
from
crnn_ctc_model
import
ctc_infer
from
attention_model
import
attention_infer
...
...
@@ -138,6 +139,7 @@ def prune(words, sos, eos):
def
main
():
args
=
parser
.
parse_args
()
print_arguments
(
args
)
check_gpu
(
args
.
use_gpu
)
if
args
.
profile
:
if
args
.
use_gpu
:
with
profiler
.
cuda_profiler
(
"cuda_profiler.txt"
,
'csv'
)
as
nvprof
:
...
...
PaddleCV/ocr_recognition/train.py
浏览文件 @
57fd89dc
...
...
@@ -4,6 +4,7 @@ from __future__ import division
from
__future__
import
print_function
import
paddle.fluid
as
fluid
from
utility
import
add_arguments
,
print_arguments
,
to_lodtensor
,
get_ctc_feeder_data
,
get_attention_feeder_data
from
utility
import
check_gpu
import
paddle.fluid.profiler
as
profiler
from
crnn_ctc_model
import
ctc_train_net
from
attention_model
import
attention_train_net
...
...
@@ -67,7 +68,9 @@ def train(args):
cycle
=
args
.
total_step
>
0
,
model
=
args
.
model
)
test_reader
=
data_reader
.
test
(
test_images_dir
=
args
.
test_images
,
test_list_file
=
args
.
test_list
,
model
=
args
.
model
)
test_images_dir
=
args
.
test_images
,
test_list_file
=
args
.
test_list
,
model
=
args
.
model
)
# prepare environment
place
=
fluid
.
CPUPlace
()
...
...
@@ -115,8 +118,8 @@ def train(args):
for
data
in
test_reader
():
exe
.
run
(
inference_program
,
feed
=
get_feeder_data
(
data
,
place
))
_
,
test_seq_error
=
error_evaluator
.
eval
(
exe
)
print
(
"
\n
Time: %s; Iter[%d]; Test seq error: %s.
\n
"
%
(
time
.
time
(),
iter_num
,
str
(
test_seq_error
[
0
])))
print
(
"
\n
Time: %s; Iter[%d]; Test seq error: %s.
\n
"
%
(
time
.
time
(),
iter_num
,
str
(
test_seq_error
[
0
])))
#Note: The following logs are special for CE monitoring.
#Other situations do not need to care about these logs.
...
...
@@ -155,10 +158,10 @@ def train(args):
iter_num
+=
1
# training log
if
iter_num
%
args
.
log_period
==
0
:
print
(
"
\n
Time: %s; Iter[%d]; Avg loss: %.3f; Avg seq err: %.3f"
%
(
time
.
time
(),
iter_num
,
total_loss
/
(
args
.
log_period
*
args
.
batch_size
),
total_seq_error
/
(
args
.
log_period
*
args
.
batch_size
)))
print
(
"
\n
Time: %s; Iter[%d]; Avg loss: %.3f; Avg seq err: %.3f"
%
(
time
.
time
(),
iter_num
,
total_loss
/
(
args
.
log_period
*
args
.
batch_size
),
total_seq_error
/
(
args
.
log_period
*
args
.
batch_size
)))
print
(
"kpis train_cost %f"
%
(
total_loss
/
(
args
.
log_period
*
args
.
batch_size
)))
print
(
"kpis train_acc %f"
%
(
...
...
@@ -203,6 +206,7 @@ def train(args):
def
main
():
args
=
parser
.
parse_args
()
print_arguments
(
args
)
check_gpu
(
args
.
use_gpu
)
if
args
.
profile
:
if
args
.
use_gpu
:
with
profiler
.
cuda_profiler
(
"cuda_profiler.txt"
,
'csv'
)
as
nvprof
:
...
...
PaddleCV/ocr_recognition/utility.py
浏览文件 @
57fd89dc
...
...
@@ -140,3 +140,22 @@ def get_attention_feeder_for_infer(data, place):
"init_ids"
:
init_ids
,
"init_scores"
:
init_scores
}
def
check_gpu
(
use_gpu
):
"""
Log error and exit when set use_gpu=true in paddlepaddle
cpu version.
"""
err
=
"Config use_gpu cannot be set as true while you are "
\
"using paddlepaddle cpu version !
\n
Please try:
\n
"
\
"
\t
1. Install paddlepaddle-gpu to run model on GPU
\n
"
\
"
\t
2. Set use_gpu as false in config file to run "
\
"model on CPU"
try
:
if
use_gpu
and
not
fluid
.
is_compiled_with_cuda
():
logger
.
error
(
err
)
sys
.
exit
(
1
)
except
Exception
as
e
:
pass
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录