@@ -227,9 +227,6 @@ def train(self):
227227 train_reader_cost = 0.0
228228 train_batch_cost = 0.0
229229 reader_start = time .time ()
230- if self .local_rank == 0 :
231- save_ckpt (self .model , self .cfg , self .optimizer , self .lr_scheduler , epoch , global_step , best_metric ,
232- is_best = False )
233230 # eval
234231 if self .local_rank == 0 and epoch > start_eval_epoch and (epoch - start_eval_epoch ) % eval_epoch_step == 0 :
235232 cur_metric = self .eval ()
@@ -245,14 +242,17 @@ def train(self):
245242 if cur_metric [self .eval_class .main_indicator ] >= best_metric [self .eval_class .main_indicator ]:
246243 best_metric .update (cur_metric )
247244 best_metric ['best_epoch' ] = epoch
248- save_ckpt (self .model , self .cfg , self .optimizer , self .lr_scheduler , epoch , global_step , best_metric ,
249- is_best = True )
250-
251245 if self .writer is not None :
252246 self .writer .add_scalar (f'EVAL/best_{ self .eval_class .main_indicator } ' ,
253247 best_metric [self .eval_class .main_indicator ], global_step )
248+ save_ckpt (self .model , self .cfg , self .optimizer , self .lr_scheduler , epoch , global_step , best_metric ,
249+ is_best = True )
254250 best_str = f"best metric, { ', ' .join (['{}: {}' .format (k , v ) for k , v in best_metric .items ()])} "
255251 self .logger .info (best_str )
252+
253+ if self .local_rank == 0 :
254+ save_ckpt (self .model , self .cfg , self .optimizer , self .lr_scheduler , epoch , global_step , best_metric ,
255+ is_best = False )
256256 best_str = f"best metric, { ', ' .join (['{}: {}' .format (k , v ) for k , v in best_metric .items ()])} "
257257 self .logger .info (best_str )
258258 if self .writer is not None :
@@ -274,7 +274,6 @@ def eval(self):
274274 for idx , batch in enumerate (self .valid_dataloader ):
275275 batch = [t .to (self .device ) for t in batch ]
276276 start = time .time ()
277- images = batch [0 ].to (self .device )
278277 if self .scaler :
279278 with torch .cuda .amp .autocast ():
280279 preds = self .model (batch [0 ], data = batch [1 :])
0 commit comments