glenn-jocher commited on
Commit
fe39562
1 Parent(s): 3a822a2

Sorted datasets update to `cache_labels()` (#4845)

Browse files

PR should produce datasets sorted alphabetically by filename. Cache version incremented to 0.5.

Note: will force a one-time re-caching of existing datasets on first-use.

Files changed (1) hide show
  1. utils/datasets.py +2 -2
utils/datasets.py CHANGED
@@ -487,7 +487,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
487
  nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages
488
  desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
489
  with Pool(NUM_THREADS) as pool:
490
- pbar = tqdm(pool.imap_unordered(verify_image_label, zip(self.img_files, self.label_files, repeat(prefix))),
491
  desc=desc, total=len(self.img_files))
492
  for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
493
  nm += nm_f
@@ -508,7 +508,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
508
  x['hash'] = get_hash(self.label_files + self.img_files)
509
  x['results'] = nf, nm, ne, nc, len(self.img_files)
510
  x['msgs'] = msgs # warnings
511
- x['version'] = 0.4 # cache version
512
  try:
513
  np.save(path, x) # save cache for next time
514
  path.with_suffix('.cache.npy').rename(path) # remove .npy suffix
 
487
  nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages
488
  desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
489
  with Pool(NUM_THREADS) as pool:
490
+ pbar = tqdm(pool.imap(verify_image_label, zip(self.img_files, self.label_files, repeat(prefix))),
491
  desc=desc, total=len(self.img_files))
492
  for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
493
  nm += nm_f
 
508
  x['hash'] = get_hash(self.label_files + self.img_files)
509
  x['results'] = nf, nm, ne, nc, len(self.img_files)
510
  x['msgs'] = msgs # warnings
511
+ x['version'] = 0.5 # cache version
512
  try:
513
  np.save(path, x) # save cache for next time
514
  path.with_suffix('.cache.npy').rename(path) # remove .npy suffix