Make cache saving optional (#2977)
This commit is contained in:
parent
a833ee2a46
commit
955eea8b96
|
|
@ -502,8 +502,11 @@ 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, i + 1
|
x['results'] = nf, nm, ne, nc, i + 1
|
||||||
x['version'] = 0.1 # cache version
|
x['version'] = 0.1 # cache version
|
||||||
torch.save(x, path) # save for next time
|
try:
|
||||||
logging.info(f'{prefix}New cache created: {path}')
|
torch.save(x, path) # save for next time
|
||||||
|
logging.info(f'{prefix}New cache created: {path}')
|
||||||
|
except Exception as e:
|
||||||
|
logging.info(f'{prefix}WARNING: Cache directory {path.parent} is not writeable: {e}') # path not writeable
|
||||||
return x
|
return x
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue