Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
e33bbd4b
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
280
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e33bbd4b
编写于
4月 02, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update run command
上级
df5cb3b2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
11 deletion
+43
-11
paddle_hub/commands/run.py
paddle_hub/commands/run.py
+43
-11
未找到文件。
paddle_hub/commands/run.py
浏览文件 @
e33bbd4b
...
...
@@ -38,21 +38,49 @@ class RunCommand(BaseCommand):
self
.
parser
=
self
.
parser
=
argparse
.
ArgumentParser
(
description
=
self
.
__class__
.
__doc__
,
prog
=
'%s %s <module>'
%
(
ENTRY
,
name
),
usage
=
'%(prog)s [options]'
)
usage
=
'%(prog)s'
,
add_help
=
False
)
def
parse_args_with_module
(
self
,
module
,
argv
):
module_type
=
module
.
type
.
lower
()
# yapf: disable
self
.
add_arg
(
'--config'
,
str
,
None
,
"config file in yaml format"
)
self
.
add_arg
(
'--dataset'
,
str
,
None
,
"dataset be used"
)
self
.
add_arg
(
'--data'
,
str
,
None
,
"data be used"
)
self
.
add_arg
(
'--signature'
,
str
,
None
,
"signature to run"
)
if
module_type
.
startswith
(
"cv"
):
self
.
add_arg
(
'--config'
,
str
,
None
,
"config file in yaml format"
)
self
.
add_arg
(
'--signature'
,
str
,
None
,
"signature to run"
)
self
.
add_arg
(
'--input_path'
,
str
,
None
,
"path of image to predict"
)
self
.
add_arg
(
'--input_file'
,
str
,
None
,
"file contain paths of images"
)
self
.
args
=
self
.
parser
.
parse_args
(
argv
[
1
:])
self
.
args
.
data
=
self
.
args
.
input_path
self
.
args
.
dataset
=
self
.
args
.
input_file
elif
module_type
.
startswith
(
"nlp"
):
self
.
add_arg
(
'--config'
,
str
,
None
,
"config file in yaml format"
)
self
.
add_arg
(
'--signature'
,
str
,
None
,
"signature to run"
)
self
.
add_arg
(
'--input_text'
,
str
,
None
,
"text to predict"
)
self
.
add_arg
(
'--input_file'
,
str
,
None
,
"file contain texts"
)
self
.
args
=
self
.
parser
.
parse_args
(
argv
)
self
.
args
.
data
=
self
.
args
.
input_text
self
.
args
.
dataset
=
self
.
args
.
input_file
# yapf: enable
def
demo_with_module
(
self
,
module
):
module_type
=
module
.
type
.
lower
()
entry
=
hub
.
commands
.
base_command
.
ENTRY
if
module_type
.
startswith
(
"cv"
):
demo
=
"%s %s %s --input_path <IMAGE_PATH>"
%
(
entry
,
self
.
name
,
module
.
name
)
elif
module_type
.
startswith
(
"nlp"
):
demo
=
"%s %s %s --input_text
\"
TEXT_TO_PREDICT
\"
"
%
(
entry
,
self
.
name
,
module
.
name
)
else
:
demo
=
"%s %s %s"
%
(
entry
,
self
.
name
,
module
.
name
)
return
demo
def
exec
(
self
,
argv
):
if
not
argv
:
print
(
"ERROR: Please specify a
key
\n
"
)
print
(
"ERROR: Please specify a
module name.
\n
"
)
self
.
help
()
return
False
module_name
=
argv
[
0
]
self
.
args
=
self
.
parser
.
parse_args
(
argv
[
1
:])
module_dir
=
default_module_manager
.
search_module
(
module_name
)
if
not
module_dir
:
...
...
@@ -67,8 +95,11 @@ class RunCommand(BaseCommand):
return
False
module
=
hub
.
Module
(
module_dir
=
module_dir
)
self
.
parse_args_with_module
(
module
,
argv
[
1
:])
if
not
module
.
default_signature
:
print
(
"ERROR! Module %s is not callable"
%
module_name
)
print
(
"ERROR! Module %s is not callable."
%
module_name
)
return
False
if
not
self
.
args
.
signature
:
self
.
args
.
signature
=
module
.
default_signature
.
name
...
...
@@ -83,9 +114,10 @@ class RunCommand(BaseCommand):
elif
self
.
args
.
dataset
:
origin_data
=
csv_reader
.
read
(
self
.
args
.
dataset
)
else
:
print
(
"ERROR! Please specify data to predict"
)
self
.
help
()
exit
(
1
)
print
(
"ERROR! Please specify data to predict.
\n
"
)
print
(
"Summary:
\n
%s"
%
module
.
summary
)
print
(
"Example:
\n
%s"
%
self
.
demo_with_module
(
module
))
return
False
# data_format check
if
not
self
.
args
.
config
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录