This commit is contained in:
552068321@qq.com 2022-11-07 21:07:23 +08:00
parent 735c7c514d
commit a78ef10b8a

View File

@ -428,11 +428,13 @@ class LoadImagesAndLabels(Dataset):
# Check cache
self.label_files = img2label_paths(self.im_files) # labels
print('labelfile############',self.label_files)
cache_path = (p if p.is_file() else Path(self.label_files[0]).parent).with_suffix('.cache')
try:
cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict
assert cache['version'] == self.cache_version # matches current version
assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical hash
print('load_cache#########')
except Exception:
cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops
@ -447,6 +449,7 @@ class LoadImagesAndLabels(Dataset):
# Read cache
[cache.pop(k) for k in ('hash', 'version', 'msgs')] # remove items
print('@@@@@@@@@@@@@@@@@@@@@')
labels, shapes, self.segments = zip(*cache.values())
nl = len(np.concatenate(labels, 0)) # number of labels
assert nl > 0 or not augment, f'{prefix}All labels empty in {cache_path}, can not start training. {HELP_URL}'