Skip to content

Commit

Permalink
Make cache saving optional (#2977)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed Apr 29, 2021
1 parent a833ee2 commit 955eea8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions utils/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,11 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''):
x['hash'] = get_hash(self.label_files + self.img_files)
x['results'] = nf, nm, ne, nc, i + 1
x['version'] = 0.1 # cache version
torch.save(x, path) # save for next time
logging.info(f'{prefix}New cache created: {path}')
try:
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

def __len__(self):
Expand Down

0 comments on commit 955eea8

Please sign in to comment.