caching introspection update

This commit is contained in:
Glenn Jocher 2020-05-22 16:03:08 -07:00
parent 002884ae5e
commit 4879fd22e9
1 changed files with 4 additions and 2 deletions

View File

@ -322,13 +322,15 @@ class LoadImagesAndLabels(Dataset): # for training/testing
nm, nf, ne, ns, nd = 0, 0, 0, 0, 0 # number missing, found, empty, datasubset, duplicate nm, nf, ne, ns, nd = 0, 0, 0, 0, 0 # number missing, found, empty, datasubset, duplicate
np_labels_path = str(Path(self.label_files[0]).parent) + '.npy' # saved labels in *.npy file np_labels_path = str(Path(self.label_files[0]).parent) + '.npy' # saved labels in *.npy file
if os.path.isfile(np_labels_path): if os.path.isfile(np_labels_path):
print('Loading labels from %s' % np_labels_path) s = np_labels_path
x = list(np.load(np_labels_path, allow_pickle=True)) x = list(np.load(np_labels_path, allow_pickle=True))
if len(x) == n: if len(x) == n:
self.labels = x self.labels = x
labels_loaded = True labels_loaded = True
else:
s = path.replace('images', 'labels')
pbar = tqdm(self.label_files, desc='Caching labels') pbar = tqdm(self.label_files)
for i, file in enumerate(pbar): for i, file in enumerate(pbar):
if labels_loaded: if labels_loaded:
l = self.labels[i] l = self.labels[i]