Cache bug fix (#1513)

* Caching bug fix #1508

* np.zeros((0,5)) x2
This commit is contained in:
Glenn Jocher authored and GitHub committed 2020-11-25 20:33:14 +01:00
1 parent b3ceffb513
commit e9a0ae6f19
3 files changed
+6 -21

No files matched your search

+2 -2
View File
@@ -443,7 +443,6 @@ class LoadImagesAndLabels(Dataset): # for training/testing
assert (shape[0] > 9) & (shape[1] > 9), 'image size <10 pixels'
# verify labels
l = []
if os.path.isfile(lb_file):
nf += 1 # label found
with open(lb_file, 'r') as f:
@@ -458,6 +457,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
l = np.zeros((0, 5), dtype=np.float32)
else:
nm += 1 # label missing
l = np.zeros((0, 5), dtype=np.float32)
x[im_file] = [l, shape]
except Exception as e:
nc += 1
@@ -470,7 +470,7 @@ class LoadImagesAndLabels(Dataset): # for training/testing
print(f'WARNING: No labels found in {path}. See {help_url}')
x['hash'] = get_hash(self.label_files + self.img_files)
x['results'] = [nf, nm, ne, nc, i]
x['results'] = [nf, nm, ne, nc, i + 1]
torch.save(x, path) # save for next time
logging.info(f"New cache created: {path}")
return x