Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
10e69bd5
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 2 年 前同步成功
通知
285
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看板
提交
10e69bd5
编写于
12月 19, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug
上级
b1e6b364
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
43 addition
and
32 deletion
+43
-32
paddlehub/commands/run.py
paddlehub/commands/run.py
+30
-27
paddlehub/module/module.py
paddlehub/module/module.py
+13
-5
未找到文件。
paddlehub/commands/run.py
浏览文件 @
10e69bd5
...
...
@@ -74,7 +74,7 @@ class RunCommand(BaseCommand):
return
hub
.
Module
(
directory
=
module_dir
[
0
])
def
add_module_config_arg
(
self
):
configs
=
self
.
module
.
configs
()
configs
=
self
.
module
.
processor
.
configs
()
for
config
in
configs
:
if
not
config
[
"dest"
].
startswith
(
"--"
):
config
[
"dest"
]
=
"--%s"
%
config
[
"dest"
]
...
...
@@ -104,7 +104,7 @@ class RunCommand(BaseCommand):
def
add_module_input_arg
(
self
):
module_type
=
self
.
module
.
type
.
lower
()
expect_data_format
=
self
.
module
.
data_format
(
expect_data_format
=
self
.
module
.
processor
.
data_format
(
self
.
module
.
default_signature
)
self
.
arg_input_group
.
add_argument
(
'--input_file'
,
...
...
@@ -144,14 +144,14 @@ class RunCommand(BaseCommand):
if
self
.
args
.
config
:
yaml_config
=
yaml_parser
.
parse
(
self
.
args
.
config
)
module_config
=
yaml_config
.
get
(
"config"
,
{})
for
_config
in
self
.
module
.
configs
():
for
_config
in
self
.
module
.
processor
.
configs
():
key
=
_config
[
'dest'
]
module_config
[
key
]
=
self
.
args
.
__dict__
[
key
]
return
module_config
def
get_data
(
self
):
module_type
=
self
.
module
.
type
.
lower
()
expect_data_format
=
self
.
module
.
data_format
(
expect_data_format
=
self
.
module
.
processor
.
data_format
(
self
.
module
.
default_signature
)
input_data
=
{}
if
len
(
expect_data_format
)
==
1
:
...
...
@@ -176,7 +176,7 @@ class RunCommand(BaseCommand):
return
input_data
def
check_data
(
self
,
data
):
expect_data_format
=
self
.
module
.
data_format
(
expect_data_format
=
self
.
module
.
processor
.
data_format
(
self
.
module
.
default_signature
)
if
len
(
data
.
keys
())
!=
len
(
expect_data_format
.
keys
()):
...
...
@@ -236,10 +236,13 @@ class RunCommand(BaseCommand):
return
False
# If the module is not executable, give an alarm and exit
if
not
self
.
module
.
default_signatur
e
:
if
not
self
.
module
.
is_runabl
e
:
print
(
"ERROR! Module %s is not executable."
%
module_name
)
return
False
if
self
.
module
.
code_version
==
"v2"
:
result
=
self
.
module
(
argv
[
1
:])
else
:
self
.
module
.
check_processor
()
self
.
add_module_config_arg
()
self
.
add_module_input_arg
()
...
...
paddlehub/module/module.py
浏览文件 @
10e69bd5
...
...
@@ -137,6 +137,7 @@ class Module(object):
version
=
None
):
if
not
directory
:
return
self
.
_code_version
=
"v2"
self
.
_directory
=
directory
self
.
module_desc_path
=
os
.
path
.
join
(
self
.
directory
,
MODULE_DESC_PBNAME
)
self
.
_desc
=
module_desc_pb2
.
ModuleDesc
()
...
...
@@ -225,6 +226,14 @@ class Module(object):
def
name_prefix
(
self
):
return
self
.
_name_prefix
@
property
def
code_version
(
self
):
return
self
.
_code_version
@
property
def
is_runable
(
self
):
return
False
class
ModuleHelper
(
object
):
def
__init__
(
self
,
directory
):
...
...
@@ -252,6 +261,7 @@ class ModuleV1(Module):
if
not
directory
:
return
super
(
ModuleV1
,
self
).
__init__
(
name
,
directory
,
module_dir
,
version
)
self
.
_code_version
=
"v1"
self
.
program
=
None
self
.
assets
=
[]
self
.
helper
=
None
...
...
@@ -501,11 +511,9 @@ class ModuleV1(Module):
if
not
self
.
processor
:
raise
ValueError
(
"This Module is not callable!"
)
def
configs
(
self
):
return
self
.
processor
.
configs
()
def
data_format
(
self
,
signature
):
return
self
.
processor
.
data_format
(
signature
)
@
property
def
is_runable
(
self
):
return
self
.
default_signature
!=
None
def
context
(
self
,
sign_name
=
None
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录