Update TQDM bar format (#6988)
This commit is contained in:
parent
932dc78496
commit
c09fb2aa95
|
|
@ -152,7 +152,7 @@ def kmean_anchors(dataset='./data/coco128.yaml', n=9, img_size=640, thr=4.0, gen
|
||||||
|
|
||||||
# Evolve
|
# Evolve
|
||||||
f, sh, mp, s = anchor_fitness(k), k.shape, 0.9, 0.1 # fitness, generations, mutation prob, sigma
|
f, sh, mp, s = anchor_fitness(k), k.shape, 0.9, 0.1 # fitness, generations, mutation prob, sigma
|
||||||
pbar = tqdm(range(gen), desc=f'{PREFIX}Evolving anchors with Genetic Algorithm:') # progress bar
|
pbar = tqdm(range(gen), bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}') # progress bar
|
||||||
for _ in pbar:
|
for _ in pbar:
|
||||||
v = np.ones(sh)
|
v = np.ones(sh)
|
||||||
while (v == 1).all(): # mutate until a change occurs (prevent duplicates)
|
while (v == 1).all(): # mutate until a change occurs (prevent duplicates)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ from utils.torch_utils import torch_distributed_zero_first
|
||||||
HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
|
HELP_URL = 'https://github.com/ultralytics/yolov5/wiki/Train-Custom-Data'
|
||||||
IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp' # include image suffixes
|
IMG_FORMATS = 'bmp', 'dng', 'jpeg', 'jpg', 'mpo', 'png', 'tif', 'tiff', 'webp' # include image suffixes
|
||||||
VID_FORMATS = 'asf', 'avi', 'gif', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'ts', 'wmv' # include video suffixes
|
VID_FORMATS = 'asf', 'avi', 'gif', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'ts', 'wmv' # include video suffixes
|
||||||
|
BAR_FORMAT = '{l_bar}{bar:10}{r_bar}{bar:-10b}' # tqdm bar format
|
||||||
|
|
||||||
# Get orientation exif tag
|
# Get orientation exif tag
|
||||||
for orientation in ExifTags.TAGS.keys():
|
for orientation in ExifTags.TAGS.keys():
|
||||||
|
|
@ -427,7 +428,7 @@ class LoadImagesAndLabels(Dataset):
|
||||||
nf, nm, ne, nc, n = cache.pop('results') # found, missing, empty, corrupt, total
|
nf, nm, ne, nc, n = cache.pop('results') # found, missing, empty, corrupt, total
|
||||||
if exists:
|
if exists:
|
||||||
d = f"Scanning '{cache_path}' images and labels... {nf} found, {nm} missing, {ne} empty, {nc} corrupt"
|
d = f"Scanning '{cache_path}' images and labels... {nf} found, {nm} missing, {ne} empty, {nc} corrupt"
|
||||||
tqdm(None, desc=prefix + d, total=n, initial=n) # display cache results
|
tqdm(None, desc=prefix + d, total=n, initial=n, bar_format=BAR_FORMAT) # display cache results
|
||||||
if cache['msgs']:
|
if cache['msgs']:
|
||||||
LOGGER.info('\n'.join(cache['msgs'])) # display warnings
|
LOGGER.info('\n'.join(cache['msgs'])) # display warnings
|
||||||
assert nf > 0 or not augment, f'{prefix}No labels in {cache_path}. Can not train without labels. See {HELP_URL}'
|
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 @@ class LoadImagesAndLabels(Dataset):
|
||||||
self.im_hw0, self.im_hw = [None] * n, [None] * n
|
self.im_hw0, self.im_hw = [None] * n, [None] * n
|
||||||
fcn = self.cache_images_to_disk if cache_images == 'disk' else self.load_image
|
fcn = self.cache_images_to_disk if cache_images == 'disk' else self.load_image
|
||||||
results = ThreadPool(NUM_THREADS).imap(fcn, range(n))
|
results = ThreadPool(NUM_THREADS).imap(fcn, range(n))
|
||||||
pbar = tqdm(enumerate(results), total=n)
|
pbar = tqdm(enumerate(results), total=n, bar_format=BAR_FORMAT)
|
||||||
for i, x in pbar:
|
for i, x in pbar:
|
||||||
if cache_images == 'disk':
|
if cache_images == 'disk':
|
||||||
gb += self.npy_files[i].stat().st_size
|
gb += self.npy_files[i].stat().st_size
|
||||||
|
|
@ -509,7 +510,7 @@ class LoadImagesAndLabels(Dataset):
|
||||||
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
|
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
|
||||||
with Pool(NUM_THREADS) as pool:
|
with Pool(NUM_THREADS) as pool:
|
||||||
pbar = tqdm(pool.imap(verify_image_label, zip(self.im_files, self.label_files, repeat(prefix))),
|
pbar = tqdm(pool.imap(verify_image_label, zip(self.im_files, self.label_files, repeat(prefix))),
|
||||||
desc=desc, total=len(self.im_files))
|
desc=desc, total=len(self.im_files), bar_format=BAR_FORMAT)
|
||||||
for im_file, lb, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
|
for im_file, lb, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
|
||||||
nm += nm_f
|
nm += nm_f
|
||||||
nf += nf_f
|
nf += nf_f
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue