Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
3bbb3567
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看板
提交
3bbb3567
编写于
3月 29, 2018
作者:
Z
zhxfl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
data load for inference
上级
59bc4c1d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
52 addition
and
32 deletion
+52
-32
fluid/DeepASR/data_utils/async_data_reader.py
fluid/DeepASR/data_utils/async_data_reader.py
+52
-32
未找到文件。
fluid/DeepASR/data_utils/async_data_reader.py
浏览文件 @
3bbb3567
...
...
@@ -102,11 +102,14 @@ class SampleInfoBucket(object):
feature_bin_path
=
self
.
_feature_bin_paths
[
block_idx
]
feature_desc_path
=
self
.
_feature_desc_paths
[
block_idx
]
label_desc_lines
=
open
(
label_desc_path
).
readlines
()
feature_desc_lines
=
open
(
feature_desc_path
).
readlines
()
label_desc_lines
=
None
if
label_desc_path
!=
""
:
label_desc_lines
=
open
(
label_desc_path
).
readlines
()
sample_num
=
int
(
label_desc_lines
[
0
].
split
()[
1
])
assert
sample_num
==
int
(
feature_desc_lines
[
0
].
split
()[
1
])
sample_num
=
int
(
feature_desc_lines
[
0
].
split
()[
1
])
if
label_desc_path
!=
""
:
assert
sample_num
==
int
(
label_desc_lines
[
0
].
split
()[
1
])
for
i
in
xrange
(
sample_num
):
feature_desc_split
=
feature_desc_lines
[
i
+
1
].
split
()
...
...
@@ -115,11 +118,15 @@ class SampleInfoBucket(object):
feature_frame_num
=
int
(
feature_desc_split
[
4
])
feature_dim
=
int
(
feature_desc_split
[
5
])
label_desc_split
=
label_desc_lines
[
i
+
1
].
split
()
label_start
=
int
(
label_desc_split
[
2
])
label_size
=
int
(
label_desc_split
[
3
])
label_frame_num
=
int
(
label_desc_split
[
4
])
assert
feature_frame_num
==
label_frame_num
label_start
=
-
1
label_size
=
-
1
label_frame_num
=
feature_frame_num
if
label_desc_path
!=
""
:
label_desc_split
=
label_desc_lines
[
i
+
1
].
split
()
label_start
=
int
(
label_desc_split
[
2
])
label_size
=
int
(
label_desc_split
[
3
])
label_frame_num
=
int
(
label_desc_split
[
4
])
assert
feature_frame_num
==
label_frame_num
if
self
.
_split_sentence_threshold
==
-
1
or
\
self
.
_split_perturb
==
-
1
or
\
...
...
@@ -187,7 +194,7 @@ class AsyncDataReader(object):
def
__init__
(
self
,
feature_file_list
,
label_file_list
,
label_file_list
=
""
,
drop_frame_len
=
512
,
proc_num
=
10
,
sample_buffer_size
=
1024
,
...
...
@@ -221,16 +228,25 @@ class AsyncDataReader(object):
def
generate_bucket_list
(
self
,
is_shuffle
):
if
self
.
_block_info_list
is
None
:
block_feature_info_lines
=
open
(
self
.
_feature_file_list
).
readlines
()
block_label_info_lines
=
open
(
self
.
_label_file_list
).
readlines
()
assert
len
(
block_feature_info_lines
)
==
len
(
block_label_info_lines
)
self
.
_block_info_list
=
[]
for
i
in
xrange
(
0
,
len
(
block_feature_info_lines
),
2
):
block_info
=
(
block_feature_info_lines
[
i
],
block_feature_info_lines
[
i
+
1
],
block_label_info_lines
[
i
],
block_label_info_lines
[
i
+
1
])
self
.
_block_info_list
.
append
(
map
(
lambda
line
:
line
.
strip
(),
block_info
))
if
self
.
_label_file_list
!=
""
:
block_label_info_lines
=
open
(
self
.
_label_file_list
).
readlines
()
#block_label_info_lines = open(self._label_file_list).readlines()
assert
len
(
block_feature_info_lines
)
==
len
(
block_label_info_lines
)
for
i
in
xrange
(
0
,
len
(
block_feature_info_lines
),
2
):
block_info
=
(
block_feature_info_lines
[
i
],
block_feature_info_lines
[
i
+
1
],
block_label_info_lines
[
i
],
block_label_info_lines
[
i
+
1
])
self
.
_block_info_list
.
append
(
map
(
lambda
line
:
line
.
strip
(),
block_info
))
else
:
for
i
in
xrange
(
0
,
len
(
block_feature_info_lines
),
2
):
block_info
=
(
block_feature_info_lines
[
i
],
block_feature_info_lines
[
i
+
1
],
""
,
""
)
self
.
_block_info_list
.
append
(
map
(
lambda
line
:
line
.
strip
(),
block_info
))
if
is_shuffle
:
self
.
_rng
.
shuffle
(
self
.
_block_info_list
)
...
...
@@ -318,19 +334,24 @@ class AsyncDataReader(object):
sample_info
.
feature_dim
,
len
(
feature_bytes
))
label_bytes
=
read_bytes
(
sample_info
.
label_bin_path
,
sample_info
.
label_start
,
sample_info
.
label_size
)
assert
sample_info
.
label_frame_num
*
4
==
len
(
label_bytes
),
(
sample_info
.
label_bin_path
,
sample_info
.
label_array
,
len
(
label_bytes
))
label_array
=
struct
.
unpack
(
'I'
*
sample_info
.
label_frame_num
,
label_bytes
)
label_data
=
np
.
array
(
label_array
,
dtype
=
'int64'
).
reshape
(
(
sample_info
.
label_frame_num
,
1
))
if
sample_info
.
label_bin_path
!=
""
:
label_bytes
=
read_bytes
(
sample_info
.
label_bin_path
,
sample_info
.
label_start
,
sample_info
.
label_size
)
assert
sample_info
.
label_frame_num
*
4
==
len
(
label_bytes
),
(
sample_info
.
label_bin_path
,
sample_info
.
label_array
,
len
(
label_bytes
))
label_array
=
struct
.
unpack
(
'I'
*
sample_info
.
label_frame_num
,
label_bytes
)
label_data
=
np
.
array
(
label_array
,
dtype
=
'int64'
).
reshape
(
(
sample_info
.
label_frame_num
,
1
))
else
:
label_data
=
np
.
zeros
(
(
sample_info
.
label_frame_num
,
1
),
dtype
=
'int64'
)
feature_frame_num
=
sample_info
.
feature_frame_num
feature_dim
=
sample_info
.
feature_dim
...
...
@@ -345,7 +366,6 @@ class AsyncDataReader(object):
for
transformer
in
self
.
_transformers
:
# @TODO(pkuyym) to make transfomer only accept feature_data
sample_data
=
transformer
.
perform_trans
(
sample_data
)
while
order_id
!=
out_order
[
0
]:
time
.
sleep
(
0.001
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录