Skip to content

Commit 73bb73b

Browse files
authored
Update TQDM bar format (ultralytics#6988)
1 parent 9326c0e commit 73bb73b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

utils/autoanchor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def print_results(k, verbose=True):
152152

153153
# Evolve
154154
f, sh, mp, s = anchor_fitness(k), k.shape, 0.9, 0.1 # fitness, generations, mutation prob, sigma
155-
pbar = tqdm(range(gen), desc=f'{PREFIX}Evolving anchors with Genetic Algorithm:') # progress bar
155+
pbar = tqdm(range(gen), bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}') # progress bar
156156
for _ in pbar:
157157
v = np.ones(sh)
158158
while (v == 1).all(): # mutate until a change occurs (prevent duplicates)

utils/datasets.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
3636
IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp' # include image suffixes
3737
VID_FORMATS = 'asf', 'avi', 'gif', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'ts', 'wmv' # include video suffixes
38+
BAR_FORMAT = '{l_bar}{bar:10}{r_bar}{bar:-10b}' # tqdm bar format
3839

3940
# Get orientation exif tag
4041
for orientation in ExifTags.TAGS.keys():
@@ -427,7 +428,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
427428
nf, nm, ne, nc, n = cache.pop('results') # found, missing, empty, corrupt, total
428429
if exists:
429430
d = f"Scanning '{cache_path}' images and labels... {nf} found, {nm} missing, {ne} empty, {nc} corrupt"
430-
tqdm(None, desc=prefix + d, total=n, initial=n) # display cache results
431+
tqdm(None, desc=prefix + d, total=n, initial=n, bar_format=BAR_FORMAT) # display cache results
431432
if cache['msgs']:
432433
LOGGER.info('\n'.join(cache['msgs'])) # display warnings
433434
assert nf > 0 or not augment, f'{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}'
@@ -492,7 +493,7 @@ def __init__(self, path, img_size=640, batch_size=16, augment=False, hyp=None, r
492493
self.im_hw0, self.im_hw = [None] * n, [None] * n
493494
fcn = self.cache_images_to_disk if cache_images == 'disk' else self.load_image
494495
results = ThreadPool(NUM_THREADS).imap(fcn, range(n))
495-
pbar = tqdm(enumerate(results), total=n)
496+
pbar = tqdm(enumerate(results), total=n, bar_format=BAR_FORMAT)
496497
for i, x in pbar:
497498
if cache_images == 'disk':
498499
gb += self.npy_files[i].stat().st_size
@@ -509,7 +510,7 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''):
509510
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
510511
with Pool(NUM_THREADS) as pool:
511512
pbar = tqdm(pool.imap(verify_image_label, zip(self.im_files, self.label_files, repeat(prefix))),
512-
desc=desc, total=len(self.im_files))
513+
desc=desc, total=len(self.im_files), bar_format=BAR_FORMAT)
513514
for im_file, lb, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
514515
nm += nm_f
515516
nf += nf_f

0 commit comments

Comments
 (0)