Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
ff0a843f
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看板
提交
ff0a843f
编写于
1月 04, 2019
作者:
Z
Zeyu Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update proto to supprot mulitiple signature
上级
5a783950
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
174 addition
and
41 deletion
+174
-41
paddle_hub/module.py
paddle_hub/module.py
+13
-1
paddle_hub/module_desc.proto
paddle_hub/module_desc.proto
+8
-8
paddle_hub/module_desc_pb2.py
paddle_hub/module_desc_pb2.py
+153
-32
未找到文件。
paddle_hub/module.py
浏览文件 @
ff0a843f
...
...
@@ -197,6 +197,12 @@ class ModuleConfig(object):
self
.
dict
=
defaultdict
(
int
)
self
.
dict
.
setdefault
(
0
)
# feed_list
self
.
feed_list
=
[]
# fetch_list
self
.
fetch_list
=
[]
def
load
(
self
):
"""load module config from module dir
"""
...
...
@@ -219,7 +225,9 @@ class ModuleConfig(object):
self
.
dict
[
w
]
=
int
(
w_id
)
def
dump
(
self
):
# save module_desc.proto first
"""
save module_desc.proto first
"""
pb_path
=
os
.
path
.
join
(
self
.
module_dir
,
"module_desc.pb"
)
with
open
(
pb_path
,
"wb"
)
as
fo
:
fo
.
write
(
self
.
desc
.
SerializeToString
())
...
...
@@ -232,6 +240,10 @@ class ModuleConfig(object):
w_id
=
self
.
dict
[
w
]
fo
.
write
(
"{}
\t
{}
\n
"
.
format
(
w
,
w_id
))
def
register_input_var
(
self
,
var
):
var_name
=
var
.
name
()
self
.
feed_list
.
add
(
var_name
)
def
save_dict
(
self
,
word_dict
,
dict_name
=
DICT_NAME
):
""" Save dictionary for NLP module
"""
...
...
paddle_hub/module_desc.proto
浏览文件 @
ff0a843f
...
...
@@ -19,11 +19,11 @@ option optimize_for = LITE_RUNTIME;
package
paddle_hub
;
message
InputDesc
{
string
name
=
1
;
repeated
string
name
=
1
;
};
message
OutputDesc
{
string
name
=
1
;
repeated
string
name
=
1
;
};
// A Hub Module is stored in a directory with a file 'paddlehub.pb'
...
...
@@ -32,14 +32,14 @@ message OutputDesc {
message
ModuleDesc
{
string
name
=
1
;
// PaddleHub module name
repeated
InputDesc
input_desc
=
2
;
// signature to input description
map
<
string
,
InputDesc
>
sign2input
=
2
;
repeated
OutputDesc
output_desc
=
3
;
// signature to output description
map
<
string
,
OutputDesc
>
sign2output
=
3
;
string
signature
=
4
;
bool
return_numpy
=
4
;
bool
return_numpy
=
5
;
bool
contain_assets
=
6
;
bool
contain_assets
=
5
;
};
paddle_hub/module_desc_pb2.py
浏览文件 @
ff0a843f
...
...
@@ -17,7 +17,7 @@ DESCRIPTOR = _descriptor.FileDescriptor(
package
=
'paddle_hub'
,
syntax
=
'proto3'
,
serialized_pb
=
_b
(
'
\n\x11
module_desc.proto
\x12\n
paddle_hub
\"\x19\n\t
InputDesc
\x12\x0c\n\x04
name
\x18\x01
\x0
1
(
\t\"\x1a\n\n
OutputDesc
\x12\x0c\n\x04
name
\x18\x01
\x01
(
\t\"\xb3\x01\n\n
ModuleDesc
\x12\x0c\n\x04
name
\x18\x01
\x01
(
\t\x12
)
\n\n
input_desc
\x18\x02
\x03
(
\x0b\x32\x15
.paddle_hub.InputDesc
\x12
+
\n\x0b
output_desc
\x18\x03
\x03
(
\x0b\x32\x16
.paddle_hub.OutputDesc
\x12\x11\n\t
signature
\x18\x04
\x01
(
\t\x12\x14\n\x0c
return_numpy
\x18\x05
\x01
(
\x08\x12\x16\n\x0e\x63
ontain_assets
\x18\x06
\x01
(
\x08
\x42\x02
H
\x03\x62\x06
proto3'
'
\n\x11
module_desc.proto
\x12\n
paddle_hub
\"\x19\n\t
InputDesc
\x12\x0c\n\x04
name
\x18\x01
\x0
3
(
\t\"\x1a\n\n
OutputDesc
\x12\x0c\n\x04
name
\x18\x01
\x03
(
\t\"\xd8\x02\n\n
ModuleDesc
\x12\x0c\n\x04
name
\x18\x01
\x01
(
\t\x12
:
\n\n
sign2input
\x18\x02
\x03
(
\x0b\x32
&.paddle_hub.ModuleDesc.Sign2inputEntry
\x12
<
\n\x0b
sign2output
\x18\x03
\x03
(
\x0b\x32\'
.paddle_hub.ModuleDesc.Sign2outputEntry
\x12\x14\n\x0c
return_numpy
\x18\x04
\x01
(
\x08\x12\x16\n\x0e\x63
ontain_assets
\x18\x05
\x01
(
\x08\x1a
H
\n\x0f
Sign2inputEntry
\x12\x0b\n\x03
key
\x18\x01
\x01
(
\t\x12
$
\n\x05
value
\x18\x02
\x01
(
\x0b\x32\x15
.paddle_hub.InputDesc:
\x02\x38\x01\x1a
J
\n\x10
Sign2outputEntry
\x12\x0b\n\x03
key
\x18\x01
\x01
(
\t\x12
%
\n\x05
value
\x18\x02
\x01
(
\x0b\x32\x16
.paddle_hub.OutputDesc:
\x02\x38\x01
\x42\x02
H
\x03\x62\x06
proto3'
))
_sym_db
.
RegisterFileDescriptor
(
DESCRIPTOR
)
...
...
@@ -35,9 +35,9 @@ _INPUTDESC = _descriptor.Descriptor(
number
=
1
,
type
=
9
,
cpp_type
=
9
,
label
=
1
,
label
=
3
,
has_default_value
=
False
,
default_value
=
_b
(
""
).
decode
(
'utf-8'
)
,
default_value
=
[]
,
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
...
...
@@ -70,9 +70,9 @@ _OUTPUTDESC = _descriptor.Descriptor(
number
=
1
,
type
=
9
,
cpp_type
=
9
,
label
=
1
,
label
=
3
,
has_default_value
=
False
,
default_value
=
_b
(
""
).
decode
(
'utf-8'
)
,
default_value
=
[]
,
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
...
...
@@ -91,16 +91,16 @@ _OUTPUTDESC = _descriptor.Descriptor(
serialized_start
=
60
,
serialized_end
=
86
,
)
_MODULEDESC
=
_descriptor
.
Descriptor
(
name
=
'
ModuleDesc
'
,
full_name
=
'paddle_hub.ModuleDesc'
,
_MODULEDESC
_SIGN2INPUTENTRY
=
_descriptor
.
Descriptor
(
name
=
'
Sign2inputEntry
'
,
full_name
=
'paddle_hub.ModuleDesc
.Sign2inputEntry
'
,
filename
=
None
,
file
=
DESCRIPTOR
,
containing_type
=
None
,
fields
=
[
_descriptor
.
FieldDescriptor
(
name
=
'
name
'
,
full_name
=
'paddle_hub.ModuleDesc.
name
'
,
name
=
'
key
'
,
full_name
=
'paddle_hub.ModuleDesc.
Sign2inputEntry.key
'
,
index
=
0
,
number
=
1
,
type
=
9
,
...
...
@@ -115,15 +115,51 @@ _MODULEDESC = _descriptor.Descriptor(
extension_scope
=
None
,
options
=
None
),
_descriptor
.
FieldDescriptor
(
name
=
'
input_desc
'
,
full_name
=
'paddle_hub.ModuleDesc.
input_desc
'
,
name
=
'
value
'
,
full_name
=
'paddle_hub.ModuleDesc.
Sign2inputEntry.value
'
,
index
=
1
,
number
=
2
,
type
=
11
,
cpp_type
=
10
,
label
=
3
,
label
=
1
,
has_default_value
=
False
,
default_value
=
[],
default_value
=
None
,
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
is_extension
=
False
,
extension_scope
=
None
,
options
=
None
),
],
extensions
=
[],
nested_types
=
[],
enum_types
=
[],
options
=
_descriptor
.
_ParseOptions
(
descriptor_pb2
.
MessageOptions
(),
_b
(
'8
\001
'
)),
is_extendable
=
False
,
syntax
=
'proto3'
,
extension_ranges
=
[],
oneofs
=
[],
serialized_start
=
285
,
serialized_end
=
357
,
)
_MODULEDESC_SIGN2OUTPUTENTRY
=
_descriptor
.
Descriptor
(
name
=
'Sign2outputEntry'
,
full_name
=
'paddle_hub.ModuleDesc.Sign2outputEntry'
,
filename
=
None
,
file
=
DESCRIPTOR
,
containing_type
=
None
,
fields
=
[
_descriptor
.
FieldDescriptor
(
name
=
'key'
,
full_name
=
'paddle_hub.ModuleDesc.Sign2outputEntry.key'
,
index
=
0
,
number
=
1
,
type
=
9
,
cpp_type
=
9
,
label
=
1
,
has_default_value
=
False
,
default_value
=
_b
(
""
).
decode
(
'utf-8'
),
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
...
...
@@ -131,26 +167,46 @@ _MODULEDESC = _descriptor.Descriptor(
extension_scope
=
None
,
options
=
None
),
_descriptor
.
FieldDescriptor
(
name
=
'
output_desc
'
,
full_name
=
'paddle_hub.ModuleDesc.
output_desc
'
,
index
=
2
,
number
=
3
,
name
=
'
value
'
,
full_name
=
'paddle_hub.ModuleDesc.
Sign2outputEntry.value
'
,
index
=
1
,
number
=
2
,
type
=
11
,
cpp_type
=
10
,
label
=
3
,
label
=
1
,
has_default_value
=
False
,
default_value
=
[]
,
default_value
=
None
,
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
is_extension
=
False
,
extension_scope
=
None
,
options
=
None
),
],
extensions
=
[],
nested_types
=
[],
enum_types
=
[],
options
=
_descriptor
.
_ParseOptions
(
descriptor_pb2
.
MessageOptions
(),
_b
(
'8
\001
'
)),
is_extendable
=
False
,
syntax
=
'proto3'
,
extension_ranges
=
[],
oneofs
=
[],
serialized_start
=
359
,
serialized_end
=
433
,
)
_MODULEDESC
=
_descriptor
.
Descriptor
(
name
=
'ModuleDesc'
,
full_name
=
'paddle_hub.ModuleDesc'
,
filename
=
None
,
file
=
DESCRIPTOR
,
containing_type
=
None
,
fields
=
[
_descriptor
.
FieldDescriptor
(
name
=
'
signatur
e'
,
full_name
=
'paddle_hub.ModuleDesc.
signatur
e'
,
index
=
3
,
number
=
4
,
name
=
'
nam
e'
,
full_name
=
'paddle_hub.ModuleDesc.
nam
e'
,
index
=
0
,
number
=
1
,
type
=
9
,
cpp_type
=
9
,
label
=
1
,
...
...
@@ -162,11 +218,43 @@ _MODULEDESC = _descriptor.Descriptor(
is_extension
=
False
,
extension_scope
=
None
,
options
=
None
),
_descriptor
.
FieldDescriptor
(
name
=
'sign2input'
,
full_name
=
'paddle_hub.ModuleDesc.sign2input'
,
index
=
1
,
number
=
2
,
type
=
11
,
cpp_type
=
10
,
label
=
3
,
has_default_value
=
False
,
default_value
=
[],
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
is_extension
=
False
,
extension_scope
=
None
,
options
=
None
),
_descriptor
.
FieldDescriptor
(
name
=
'sign2output'
,
full_name
=
'paddle_hub.ModuleDesc.sign2output'
,
index
=
2
,
number
=
3
,
type
=
11
,
cpp_type
=
10
,
label
=
3
,
has_default_value
=
False
,
default_value
=
[],
message_type
=
None
,
enum_type
=
None
,
containing_type
=
None
,
is_extension
=
False
,
extension_scope
=
None
,
options
=
None
),
_descriptor
.
FieldDescriptor
(
name
=
'return_numpy'
,
full_name
=
'paddle_hub.ModuleDesc.return_numpy'
,
index
=
4
,
number
=
5
,
index
=
3
,
number
=
4
,
type
=
8
,
cpp_type
=
7
,
label
=
1
,
...
...
@@ -181,8 +269,8 @@ _MODULEDESC = _descriptor.Descriptor(
_descriptor
.
FieldDescriptor
(
name
=
'contain_assets'
,
full_name
=
'paddle_hub.ModuleDesc.contain_assets'
,
index
=
5
,
number
=
6
,
index
=
4
,
number
=
5
,
type
=
8
,
cpp_type
=
7
,
label
=
1
,
...
...
@@ -196,7 +284,10 @@ _MODULEDESC = _descriptor.Descriptor(
options
=
None
),
],
extensions
=
[],
nested_types
=
[],
nested_types
=
[
_MODULEDESC_SIGN2INPUTENTRY
,
_MODULEDESC_SIGN2OUTPUTENTRY
,
],
enum_types
=
[],
options
=
None
,
is_extendable
=
False
,
...
...
@@ -204,10 +295,16 @@ _MODULEDESC = _descriptor.Descriptor(
extension_ranges
=
[],
oneofs
=
[],
serialized_start
=
89
,
serialized_end
=
268
,
)
serialized_end
=
433
,
)
_MODULEDESC
.
fields_by_name
[
'input_desc'
].
message_type
=
_INPUTDESC
_MODULEDESC
.
fields_by_name
[
'output_desc'
].
message_type
=
_OUTPUTDESC
_MODULEDESC_SIGN2INPUTENTRY
.
fields_by_name
[
'value'
].
message_type
=
_INPUTDESC
_MODULEDESC_SIGN2INPUTENTRY
.
containing_type
=
_MODULEDESC
_MODULEDESC_SIGN2OUTPUTENTRY
.
fields_by_name
[
'value'
].
message_type
=
_OUTPUTDESC
_MODULEDESC_SIGN2OUTPUTENTRY
.
containing_type
=
_MODULEDESC
_MODULEDESC
.
fields_by_name
[
'sign2input'
].
message_type
=
_MODULEDESC_SIGN2INPUTENTRY
_MODULEDESC
.
fields_by_name
[
'sign2output'
].
message_type
=
_MODULEDESC_SIGN2OUTPUTENTRY
DESCRIPTOR
.
message_types_by_name
[
'InputDesc'
]
=
_INPUTDESC
DESCRIPTOR
.
message_types_by_name
[
'OutputDesc'
]
=
_OUTPUTDESC
DESCRIPTOR
.
message_types_by_name
[
'ModuleDesc'
]
=
_MODULEDESC
...
...
@@ -236,13 +333,37 @@ ModuleDesc = _reflection.GeneratedProtocolMessageType(
'ModuleDesc'
,
(
_message
.
Message
,
),
dict
(
Sign2inputEntry
=
_reflection
.
GeneratedProtocolMessageType
(
'Sign2inputEntry'
,
(
_message
.
Message
,
),
dict
(
DESCRIPTOR
=
_MODULEDESC_SIGN2INPUTENTRY
,
__module__
=
'module_desc_pb2'
# @@protoc_insertion_point(class_scope:paddle_hub.ModuleDesc.Sign2inputEntry)
)),
Sign2outputEntry
=
_reflection
.
GeneratedProtocolMessageType
(
'Sign2outputEntry'
,
(
_message
.
Message
,
),
dict
(
DESCRIPTOR
=
_MODULEDESC_SIGN2OUTPUTENTRY
,
__module__
=
'module_desc_pb2'
# @@protoc_insertion_point(class_scope:paddle_hub.ModuleDesc.Sign2outputEntry)
)),
DESCRIPTOR
=
_MODULEDESC
,
__module__
=
'module_desc_pb2'
# @@protoc_insertion_point(class_scope:paddle_hub.ModuleDesc)
))
_sym_db
.
RegisterMessage
(
ModuleDesc
)
_sym_db
.
RegisterMessage
(
ModuleDesc
.
Sign2inputEntry
)
_sym_db
.
RegisterMessage
(
ModuleDesc
.
Sign2outputEntry
)
DESCRIPTOR
.
has_options
=
True
DESCRIPTOR
.
_options
=
_descriptor
.
_ParseOptions
(
descriptor_pb2
.
FileOptions
(),
_b
(
'H
\003
'
))
_MODULEDESC_SIGN2INPUTENTRY
.
has_options
=
True
_MODULEDESC_SIGN2INPUTENTRY
.
_options
=
_descriptor
.
_ParseOptions
(
descriptor_pb2
.
MessageOptions
(),
_b
(
'8
\001
'
))
_MODULEDESC_SIGN2OUTPUTENTRY
.
has_options
=
True
_MODULEDESC_SIGN2OUTPUTENTRY
.
_options
=
_descriptor
.
_ParseOptions
(
descriptor_pb2
.
MessageOptions
(),
_b
(
'8
\001
'
))
# @@protoc_insertion_point(module_scope)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录