zzttqu commited on
Commit
1e8ab3f
1 Parent(s): 2bf34f5

Add tqdm pbar.close() (#2644)

Browse files

When using tqdm, sometimes it can't print in one line and roll to next line.

Files changed (1) hide show
  1. utils/datasets.py +4 -2
utils/datasets.py CHANGED
@@ -443,7 +443,8 @@ class LoadImagesAndLabels(Dataset): # for training/testing
443
  self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i)
444
  gb += self.imgs[i].nbytes
445
  pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB)'
446
-
 
447
  def cache_labels(self, path=Path('./labels.cache'), prefix=''):
448
  # Cache dataset labels, check images and read shapes
449
  x = {} # dict
@@ -487,7 +488,8 @@ class LoadImagesAndLabels(Dataset): # for training/testing
487
 
488
  pbar.desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels... " \
489
  f"{nf} found, {nm} missing, {ne} empty, {nc} corrupted"
490
-
 
491
  if nf == 0:
492
  print(f'{prefix}WARNING: No labels found in {path}. See {help_url}')
493
 
 
443
  self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i)
444
  gb += self.imgs[i].nbytes
445
  pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB)'
446
+ pbar.close()
447
+
448
  def cache_labels(self, path=Path('./labels.cache'), prefix=''):
449
  # Cache dataset labels, check images and read shapes
450
  x = {} # dict
 
488
 
489
  pbar.desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels... " \
490
  f"{nf} found, {nm} missing, {ne} empty, {nc} corrupted"
491
+ pbar.close()
492
+
493
  if nf == 0:
494
  print(f'{prefix}WARNING: No labels found in {path}. See {help_url}')
495