glenn-jocher
commited on
Commit
•
8d52c1c
1
Parent(s):
ed65187
Update datasets.py (#3531)
Browse filesMinor updates to https://github.com/ultralytics/yolov5/pull/3505, inplace accumulation.
- utils/datasets.py +6 -5
utils/datasets.py
CHANGED
@@ -462,19 +462,20 @@ class LoadImagesAndLabels(Dataset): # for training/testing
|
|
462 |
nm, nf, ne, nc = 0, 0, 0, 0 # number missing, found, empty, corrupt
|
463 |
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
|
464 |
with Pool(num_threads) as pool:
|
465 |
-
pbar = tqdm(pool.imap_unordered(verify_image_label,
|
466 |
-
zip(self.img_files, self.label_files, repeat(prefix))),
|
467 |
desc=desc, total=len(self.img_files))
|
468 |
for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f in pbar:
|
|
|
|
|
|
|
|
|
469 |
if im_file:
|
470 |
x[im_file] = [l, shape, segments]
|
471 |
-
nm, nf, ne, nc = nm + nm_f, nf + nf_f, ne + ne_f, nc + nc_f
|
472 |
pbar.desc = f"{desc}{nf} found, {nm} missing, {ne} empty, {nc} corrupted"
|
473 |
-
pbar.close()
|
474 |
|
|
|
475 |
if nf == 0:
|
476 |
logging.info(f'{prefix}WARNING: No labels found in {path}. See {help_url}')
|
477 |
-
|
478 |
x['hash'] = get_hash(self.label_files + self.img_files)
|
479 |
x['results'] = nf, nm, ne, nc, len(self.img_files)
|
480 |
x['version'] = 0.2 # cache version
|
|
|
462 |
nm, nf, ne, nc = 0, 0, 0, 0 # number missing, found, empty, corrupt
|
463 |
desc = f"{prefix}Scanning '{path.parent / path.stem}' images and labels..."
|
464 |
with Pool(num_threads) as pool:
|
465 |
+
pbar = tqdm(pool.imap_unordered(verify_image_label, zip(self.img_files, self.label_files, repeat(prefix))),
|
|
|
466 |
desc=desc, total=len(self.img_files))
|
467 |
for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f in pbar:
|
468 |
+
nm += nm_f
|
469 |
+
nf += nf_f
|
470 |
+
ne += ne_f
|
471 |
+
nc += nc_f
|
472 |
if im_file:
|
473 |
x[im_file] = [l, shape, segments]
|
|
|
474 |
pbar.desc = f"{desc}{nf} found, {nm} missing, {ne} empty, {nc} corrupted"
|
|
|
475 |
|
476 |
+
pbar.close()
|
477 |
if nf == 0:
|
478 |
logging.info(f'{prefix}WARNING: No labels found in {path}. See {help_url}')
|
|
|
479 |
x['hash'] = get_hash(self.label_files + self.img_files)
|
480 |
x['results'] = nf, nm, ne, nc, len(self.img_files)
|
481 |
x['version'] = 0.2 # cache version
|