Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ruotianluo committed Jul 6, 2020
1 parent 4e4d5f2 commit b232d49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion captioning/data/dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def __init__(self, db_path, ext, in_memory=False):
if self.ext == '.npy':
self.loader = lambda x: np.load(six.BytesIO(x))
else:
self.loader = lambda x: np.load(six.BytesIO(x))['feat']
def load_npz(x):
x = np.load(six.BytesIO(x))
return x['feat'] if 'feat' in x else x['z'] # normally it should be 'feat', but under cocotest_bu, the key is saved to be 'z' mistakenly.
self.loader = load_npz
if db_path.endswith('.lmdb'):
self.db_type = 'lmdb'
self.env = lmdb.open(db_path, subdir=os.path.isdir(db_path),
Expand Down Expand Up @@ -386,6 +389,8 @@ def __next__(self):
wrapped = True
else:
raise StopIteration()
if len(self._index_list) == 0: # overflow when 0 samples
return None
elem = (self._index_list[self.iter_counter], self.iter_counter+1, wrapped)
self.iter_counter += 1
return elem
Expand Down

0 comments on commit b232d49

Please sign in to comment.