Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Jul 21, 2020
1 parent 621e6b3 commit 09481c3
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,15 @@ def __next__(self):
# print('queue', self.tids[batch_current], batch_size)
tids = np.array(self.tids[batch_current:batch_current+batch_size])

delIdx = []
for i, tid in enumerate(tids):
batch_size = 0
for tid in tids:
try:
self.X[i] = self.loader.load(get_audio_path(audio_dir, tid))
audio_path = get_audio_path(audio_dir, tid)
self.X[batch_size] = self.loader.load(audio_path)
self.Y[batch_size] = Y.loc[tid]
batch_size += 1
except Exception as e:
delIdx.append(i)
print("\nERROR LOADING FILE at index", i, ":", e)
self.Y[i] = Y.loc[tid]


if len(delIdx) > 0:
print("\nDeleting the following failed cases:", delIdx)
self.X = np.delete(self.X, delIdx, axis=0)
self.Y = np.delete(self.Y, delIdx, axis=0)
print(f"Ignoring {audio_path} (error: {e}).")

with self.lock2:
while (batch_current - self.batch_rearmost.value) % self.tids.size > self.batch_size:
Expand Down

0 comments on commit 09481c3

Please sign in to comment.