Unverified 提交 fe39562a authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Sorted datasets update to `cache_labels()` (#4845)

PR should produce datasets sorted alphabetically by filename. Cache version incremented to 0.5. Note: will force a one-time re-caching of existing datasets on first-use.
上级 3a822a22
...@@ -487,7 +487,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing ...@@ -487,7 +487,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages nm, nf, ne, nc, msgs = 0, 0, 0, 0, [] # number missing, found, empty, corrupt, messages
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_unordered(verify_image_label, zip(self.img_files, self.label_files, repeat(prefix))), pbar = tqdm(pool.imap(verify_image_label, zip(self.img_files, self.label_files, repeat(prefix))),
desc=desc, total=len(self.img_files)) desc=desc, total=len(self.img_files))
for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar: for im_file, l, shape, segments, nm_f, nf_f, ne_f, nc_f, msg in pbar:
nm += nm_f nm += nm_f
...@@ -508,7 +508,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing ...@@ -508,7 +508,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
x['hash'] = get_hash(self.label_files + self.img_files) x['hash'] = get_hash(self.label_files + self.img_files)
x['results'] = nf, nm, ne, nc, len(self.img_files) x['results'] = nf, nm, ne, nc, len(self.img_files)
x['msgs'] = msgs # warnings x['msgs'] = msgs # warnings
x['version'] = 0.4 # cache version x['version'] = 0.5 # cache version
try: try:
np.save(path, x) # save cache for next time np.save(path, x) # save cache for next time
path.with_suffix('.cache.npy').rename(path) # remove .npy suffix path.with_suffix('.cache.npy').rename(path) # remove .npy suffix
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论