Skip to content

Commit 74b3886

Browse files
Simplify dataloader tqdm descriptions (#10210)
* Simplify dataloader tqdm descriptions @AyushExel this should help our tqdm dataloader messages fit better within a single line in our Colab notebooks and also help avoid confusion about missing/empty labels, now combined into 'backgrounds'. Signed-off-by: Glenn Jocher <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update dataloaders.py Signed-off-by: Glenn Jocher <[email protected]> Signed-off-by: Glenn Jocher <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 946765b commit 74b3886

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

utils/dataloaders.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from utils.augmentations import (Albumentations, augment_hsv, classify_albumentations, classify_transforms, copy_paste,
3232
cutout, letterbox, mixup, random_perspective)
3333
from utils.general import (DATASETS_DIR, LOGGER, NUM_THREADS, check_dataset, check_requirements, check_yaml, clean_str,
34-
colorstr, cv2, is_colab, is_kaggle, segments2boxes, unzip_file, xyn2xy, xywh2xyxy,
35-
xywhn2xyxy, xyxy2xywhn)
34+
cv2, is_colab, is_kaggle, segments2boxes, unzip_file, xyn2xy, xywh2xyxy, xywhn2xyxy,
35+
xyxy2xywhn)
3636
from utils.torch_utils import torch_distributed_zero_first
3737

3838
# Parameters
@@ -493,7 +493,7 @@ def __init__(self,
493493
# Display cache
494494
nf, nm, ne, nc, n = cache.pop('results') # found, missing, empty, corrupt, total
495495
if exists and LOCAL_RANK in {-1, 0}:
496-
d = f"Scanning '{cache_path}' images and labels... {nf} found, {nm} missing, {ne} empty, {nc} corrupt"
496+
d = f"Scanning {cache_path}... {nf} images, {nm + ne} backgrounds, {nc} corrupt"
497497
tqdm(None, desc=prefix + d, total=n, initial=n, bar_format=BAR_FORMAT) # display cache results
498498
if cache['msgs']:
499499
LOGGER.info('\n'.join(cache['msgs'])) # display warnings
@@ -607,7 +607,7 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''):
607607
# Cache dataset labels, check images and read shapes
608608
x = {} # dict
609609
nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages
610-
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
610+
desc = f"{prefix}Scanning {path.parent / path.stem}..."
611611
with Pool(NUM_THREADS) as pool:
612612
pbar = tqdm(pool.imap(verify_image_label, zip(self.im_files, self.label_files, repeat(prefix))),
613613
desc=desc,
@@ -622,7 +622,7 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''):
622622
x[im_file] = [lb, shape, segments]
623623
if msg:
624624
msgs.append(msg)
625-
pbar.desc = f"{desc}{nf} found, {nm} missing, {ne} empty, {nc} corrupt"
625+
pbar.desc = f"{desc} {nf} images, {nm + ne} backgrounds, {nc} corrupt"
626626

627627
pbar.close()
628628
if msgs:

0 commit comments

Comments
 (0)