修改cache存在报错情况

This commit is contained in:
552068321@qq.com 2022-11-11 10:54:30 +08:00
parent 24b0272528
commit cb1033b661
3 changed files with 7 additions and 5 deletions

View File

@ -312,7 +312,6 @@ def Export_model_RODY(params_str):
return exp_outputPath return exp_outputPath
@obtain_train_param() @obtain_train_param()
def returnTrainParams(): def returnTrainParams():
# nvmlInit() # nvmlInit()

View File

@ -72,7 +72,7 @@ def yaml_rewrite(file='data.yaml',data_list=[]):
with open(file, errors='ignore') as f: with open(file, errors='ignore') as f:
coco_dict = yaml.safe_load(f) coco_dict = yaml.safe_load(f)
#读取img_label_type.json #读取img_label_type.json
with open(data_list[3], 'r') as f: with open(data_list[3], 'r',encoding='UTF-8') as f:
class_dict = json.load(f) class_dict = json.load(f)
f.close() f.close()
classes = class_dict["classes"] classes = class_dict["classes"]

View File

@ -430,9 +430,12 @@ class LoadImagesAndLabels(Dataset):
self.label_files = img2label_paths(self.im_files) # labels self.label_files = img2label_paths(self.im_files) # labels
cache_path = (p if p.is_file() else Path(self.label_files[0]).parent).with_suffix('.cache') cache_path = (p if p.is_file() else Path(self.label_files[0]).parent).with_suffix('.cache')
try: try:
cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict # cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict
assert cache['version'] == self.cache_version # matches current version # assert cache['version'] == self.cache_version # matches current version
assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical has # assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical has
if os.path.exists(cache_path):
os.remove(cache_path)
cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops
except Exception: except Exception:
cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops