glenn-jocher commited on
Commit
955eea8
·
unverified ·
1 Parent(s): a833ee2

Make cache saving optional (#2977)

Browse files
Files changed (1) hide show
  1. utils/datasets.py +5 -2
utils/datasets.py CHANGED
@@ -502,8 +502,11 @@ class LoadImagesAndLabels(Dataset): # for training/testing
502
  x['hash'] = get_hash(self.label_files + self.img_files)
503
  x['results'] = nf, nm, ne, nc, i + 1
504
  x['version'] = 0.1 # cache version
505
- torch.save(x, path) # save for next time
506
- logging.info(f'{prefix}New cache created: {path}')
 
 
 
507
  return x
508
 
509
  def __len__(self):
 
502
  x['hash'] = get_hash(self.label_files + self.img_files)
503
  x['results'] = nf, nm, ne, nc, i + 1
504
  x['version'] = 0.1 # cache version
505
+ try:
506
+ torch.save(x, path) # save for next time
507
+ logging.info(f'{prefix}New cache created: {path}')
508
+ except Exception as e:
509
+ logging.info(f'{prefix}WARNING: Cache directory {path.parent} is not writeable: {e}') # path not writeable
510
  return x
511
 
512
  def __len__(self):