From 1e8ab3f5f2048b91f8f5e8ec0b15fe855853eebc Mon Sep 17 00:00:00 2001 From: zzttqu <80448114+zzttqu@users.noreply.github.com> Date: Mon, 29 Mar 2021 05:21:25 -0500 Subject: [PATCH] Add tqdm pbar.close() (#2644) When using tqdm, sometimes it can't print in one line and roll to next line. --- utils/datasets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/datasets.py b/utils/datasets.py index dfe1dcc52971..5ef89ab6ea83 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -443,7 +443,8 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r self.imgs[i], self.img_hw0[i], self.img_hw[i] = x # img, hw_original, hw_resized = load_image(self, i) gb += self.imgs[i].nbytes pbar.desc = f'{prefix}Caching images ({gb / 1E9:.1f}GB)' - + pbar.close() + def cache_labels(self, path=Path('./labels.cache'), prefix=''): # Cache dataset labels, check images and read shapes x = {} # dict @@ -487,7 +488,8 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''): pbar.desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels... " \ f"{nf} found, {nm} missing, {ne} empty, {nc} corrupted" - + pbar.close() + if nf == 0: print(f'{prefix}WARNING: No labels found in {path}. See {help_url}')