Browse Source

Make cache saving optional (#2977)

modifyDataloader
Glenn Jocher GitHub 3 years ago
parent
commit
955eea8b96
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions
  1. +5
    -2
      utils/datasets.py

+ 5
- 2
utils/datasets.py View File

@@ -502,8 +502,11 @@ class LoadImagesAndLabels(Dataset): # for training/testing
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):

Loading…
Cancel
Save