|
|
@@ -35,6 +35,7 @@ from utils.torch_utils import torch_distributed_zero_first |
|
|
|
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 |
|
|
|
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 |
|
|
|
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 |
|
|
|
if exists: |
|
|
|
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']: |
|
|
|
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}' |
|
|
@@ -492,7 +493,7 @@ class LoadImagesAndLabels(Dataset): |
|
|
|
self.im_hw0, self.im_hw = [None] * n, [None] * n |
|
|
|
fcn = self.cache_images_to_disk if cache_images == 'disk' else self.load_image |
|
|
|
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: |
|
|
|
if cache_images == 'disk': |
|
|
|
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..." |
|
|
|
with Pool(NUM_THREADS) as pool: |
|
|
|
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: |
|
|
|
nm += nm_f |
|
|
|
nf += nf_f |