Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
6c167379
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
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看板
提交
6c167379
编写于
3月 12, 2019
作者:
W
wuzewu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update run command
上级
c8193062
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
11 deletion
+37
-11
paddle_hub/commands/run.py
paddle_hub/commands/run.py
+7
-5
paddle_hub/module/module.py
paddle_hub/module/module.py
+30
-6
未找到文件。
paddle_hub/commands/run.py
浏览文件 @
6c167379
...
...
@@ -82,7 +82,8 @@ class RunCommand(BaseCommand):
assert
len
(
input_data_format
)
==
len
(
expect_data_format
)
for
key
,
value
in
expect_data_format
.
items
():
assert
key
in
input_data_format
assert
value
==
hub
.
DataType
.
type
(
input_data_format
[
key
][
'type'
])
assert
value
[
'type'
]
==
hub
.
DataType
.
type
(
input_data_format
[
key
][
'type'
])
# get data dict
origin_data
=
csv_reader
.
read
(
self
.
args
.
dataset
)
...
...
@@ -93,10 +94,11 @@ class RunCommand(BaseCommand):
map
(
type_reader
.
read
,
origin_data
[
value
[
'key'
]]))
# run module with data
module
(
sign_name
=
self
.
args
.
signature
,
data
=
input_data
,
**
yaml_config
[
'config'
])
print
(
module
(
sign_name
=
self
.
args
.
signature
,
data
=
input_data
,
**
yaml_config
[
'config'
]))
command
=
RunCommand
.
instance
()
paddle_hub/module/module.py
浏览文件 @
6c167379
...
...
@@ -331,23 +331,47 @@ class Module:
module_info
.
map
.
data
[
'summary'
])
def
__call__
(
self
,
sign_name
,
data
,
**
kwargs
):
def
_get_reader_and_feeder
(
data_format
,
data
,
place
):
def
_reader
():
nonlocal
process_data
for
item
in
zip
(
*
process_data
):
yield
item
process_data
=
[]
feed_name_list
=
[]
for
key
in
data_format
:
process_data
.
append
([
value
[
'processed'
]
for
value
in
data
[
key
]])
feed_name_list
.
append
(
data_format
[
key
][
'feed_key'
])
feeder
=
fluid
.
DataFeeder
(
feed_list
=
feed_name_list
,
place
=
place
)
return
_reader
,
feeder
feed_dict
,
fetch_dict
,
program
=
self
.
context
(
sign_name
,
for_test
=
True
)
#TODO(wuzewu): more option
reader
=
self
.
processor
.
reader
(
sign_name
=
sign_name
,
data_dict
=
data
,
**
kwargs
)
feed_name_list
=
list
(
set
([
value
.
name
for
key
,
value
in
feed_dict
.
items
()]))
fetch_list
=
list
(
set
([
value
for
key
,
value
in
fetch_dict
.
items
()]))
with
fluid
.
program_guard
(
program
):
result
=
[]
index
=
0
place
=
fluid
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
=
place
)
feeder
=
fluid
.
DataFeeder
(
feed_list
=
feed_name_list
,
place
=
place
)
data
=
self
.
processor
.
preprocess
(
sign_name
=
sign_name
,
data_dict
=
data
)
data_format
=
self
.
processor
.
data_format
(
sign_name
=
sign_name
)
reader
,
feeder
=
_get_reader_and_feeder
(
data_format
,
data
,
place
)
reader
=
paddle
.
batch
(
reader
,
batch_size
=
2
)
for
batch
in
reader
():
data_out
=
exe
.
run
(
feed
=
feeder
.
feed
(
batch
),
fetch_list
=
fetch_list
,
return_numpy
=
False
)
self
.
processor
.
postprocess
(
sign_name
,
data_out
,
**
kwargs
)
sub_data
=
{
key
:
value
[
index
:
index
+
len
(
batch
)]
for
key
,
value
in
data
.
items
()
}
result
+=
self
.
processor
.
postprocess
(
sign_name
,
data_out
,
sub_data
,
**
kwargs
)
index
+=
len
(
batch
)
return
result
def
context
(
self
,
sign_name
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录