未验证 提交 60094207 编写于 作者: L lujun 提交者: GitHub

fix dataset-flowers random fail. test=develop (#17836)

fix flower-dataset unclose error
上级 674e0ce2
...@@ -117,7 +117,8 @@ def reader_creator(data_file, ...@@ -117,7 +117,8 @@ def reader_creator(data_file,
def reader(): def reader():
while True: while True:
for file in open(file_list): with open(file_list, 'r') as f_list:
for file in f_list:
file = file.strip() file = file.strip()
batch = None batch = None
with open(file, 'rb') as f: with open(file, 'rb') as f:
...@@ -125,11 +126,13 @@ def reader_creator(data_file, ...@@ -125,11 +126,13 @@ def reader_creator(data_file,
batch = pickle.load(f) batch = pickle.load(f)
else: else:
batch = pickle.load(f, encoding='bytes') batch = pickle.load(f, encoding='bytes')
if six.PY3: if six.PY3:
batch = cpt.to_text(batch) batch = cpt.to_text(batch)
data = batch['data'] data_batch = batch['data']
labels = batch['label'] labels_batch = batch['label']
for sample, label in six.moves.zip(data, batch['label']): for sample, label in six.moves.zip(data_batch,
labels_batch):
yield sample, int(label) - 1 yield sample, int(label) - 1
if not cycle: if not cycle:
break break
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册