Skip to content

Commit

Permalink
Skip existing npy
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Aug 2, 2021
1 parent fa7e4ce commit 7c51880
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
results = ThreadPool(NUM_THREADS).imap(lambda x: load_image(*x), zip(repeat(self), range(n)))
pbar = tqdm(enumerate(results), total=n)
for i, x in pbar:
im, self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i)
if cache_images == 'disk':
np.save(self.img_npy[i].as_posix(), im)
if not self.img_npy[i].exists():
np.save(self.img_npy[i].as_posix(), x[0])
gb += self.img_npy[i].stat().st_size
else:
self.imgs[i] = im
self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # im, hw_orig, hw_resized = load_image(self, i)
gb += self.imgs[i].nbytes
pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB {cache_images})'
pbar.close()
Expand Down

0 comments on commit 7c51880

Please sign in to comment.