From cb1033b6616accd62931033a875532ebe6335c98 Mon Sep 17 00:00:00 2001 From: "552068321@qq.com" Date: Fri, 11 Nov 2022 10:54:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cache=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/AlgorithmController.py | 1 - app/yolov5/train_server.py | 2 +- app/yolov5/utils/dataloaders.py | 9 ++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controller/AlgorithmController.py b/app/controller/AlgorithmController.py index 75d7c38..121afbc 100644 --- a/app/controller/AlgorithmController.py +++ b/app/controller/AlgorithmController.py @@ -312,7 +312,6 @@ def Export_model_RODY(params_str): return exp_outputPath - @obtain_train_param() def returnTrainParams(): # nvmlInit() diff --git a/app/yolov5/train_server.py b/app/yolov5/train_server.py index 07ff125..c122f9d 100644 --- a/app/yolov5/train_server.py +++ b/app/yolov5/train_server.py @@ -72,7 +72,7 @@ def yaml_rewrite(file='data.yaml',data_list=[]): with open(file, errors='ignore') as f: coco_dict = yaml.safe_load(f) #读取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) f.close() classes = class_dict["classes"] diff --git a/app/yolov5/utils/dataloaders.py b/app/yolov5/utils/dataloaders.py index 90de966..9b8a9b8 100644 --- a/app/yolov5/utils/dataloaders.py +++ b/app/yolov5/utils/dataloaders.py @@ -430,9 +430,12 @@ class LoadImagesAndLabels(Dataset): 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') try: - cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict - assert cache['version'] == self.cache_version # matches current version - assert cache['hash'] == get_hash(self.label_files + self.im_files) # identical has + # cache, exists = np.load(cache_path, allow_pickle=True).item(), True # load dict + # assert cache['version'] == self.cache_version # matches current version + # 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: cache, exists = self.cache_labels(cache_path, prefix), False # run cache ops