diff --git a/tools/program.py b/tools/program.py index 72fca1482b4a74547ad77b9a0b28de111c8d7a5d..9e1b3a72c0c534f93b4916ca49381b6c98402e64 100755 --- a/tools/program.py +++ b/tools/program.py @@ -380,7 +380,8 @@ def train(config, epoch=epoch, global_step=global_step) - log_writer.log_model(is_best=False, prefix="latest") + if log_writer is not None: + log_writer.log_model(is_best=False, prefix="latest") if dist.get_rank() == 0 and epoch > 0 and epoch % save_epoch_step == 0: save_model( @@ -394,8 +395,8 @@ def train(config, best_model_dict=best_model_dict, epoch=epoch, global_step=global_step) - - log_writer.log_model(is_best=False, prefix='iter_epoch_{}'.format(epoch)) + if log_writer is not None: + log_writer.log_model(is_best=False, prefix='iter_epoch_{}'.format(epoch)) best_str = 'best metric, {}'.format(', '.join( ['{}: {}'.format(k, v) for k, v in best_model_dict.items()]))