@@ -150,10 +150,7 @@ def forward(self):
150150 # create data dictionary
151151 data_dict = self .generate_data_dict ()
152152
153- if self .output_folder :
154- self .label_dict = self .label_dict_creation (data_dict )
155- else :
156- self .label_dict = None
153+ self .label_dict = self .label_dict_creation (data_dict )
157154
158155 self .data_len = len (data_dict ["data_list" ])
159156
@@ -332,11 +329,12 @@ def numpy2torch(self, data_list):
332329 def label_dict_creation (self , data_dict ): # noqa: C901
333330 logger .warning ("label_dict_creation is too complex, please fix" )
334331
335- label_dict_file = self .output_folder + "/label_dict.pkl"
332+ if self .output_folder is not None :
333+ label_dict_file = self .output_folder + "/label_dict.pkl"
336334
337- # Read previously stored label_dict
338- if os .path .isfile (label_dict_file ):
339- label_dict = load_pkl (label_dict_file )
335+ # Read previously stored label_dict
336+ if os .path .isfile (label_dict_file ):
337+ label_dict = load_pkl (label_dict_file )
340338 else :
341339 # create label counts and label2index automatically when needed
342340 label_dict = {}
@@ -412,7 +410,8 @@ def label_dict_creation(self, data_dict): # noqa: C901
412410 cnt_id = cnt_id + 1
413411
414412 # saving the label_dict:
415- save_pkl (label_dict , label_dict_file )
413+ if self .output_folder is not None :
414+ save_pkl (label_dict , label_dict_file )
416415
417416 return label_dict
418417
0 commit comments