glenn-jocher commited on
Commit
752d97d
1 Parent(s): 13f7275

Add `on_fit_epoch_end` callback (#5232)

Browse files

* Add `on_fit_epoch_end` callback

* Add results to train

* Update __init__.py

Files changed (2) hide show
  1. train.py +3 -1
  2. utils/loggers/__init__.py +1 -1
train.py CHANGED
@@ -423,8 +423,10 @@ def train(hyp, # path/to/hyp.yaml or hyp dictionary
423
  plots=True,
424
  callbacks=callbacks,
425
  compute_loss=compute_loss) # val best model with plots
 
 
426
 
427
- callbacks.run('on_train_end', last, best, plots, epoch)
428
  LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}")
429
 
430
  torch.cuda.empty_cache()
 
423
  plots=True,
424
  callbacks=callbacks,
425
  compute_loss=compute_loss) # val best model with plots
426
+ if is_coco:
427
+ callbacks.run('on_fit_epoch_end', list(mloss) + list(results) + lr, epoch, best_fitness, fi)
428
 
429
+ callbacks.run('on_train_end', last, best, plots, epoch, results)
430
  LOGGER.info(f"Results saved to {colorstr('bold', save_dir)}")
431
 
432
  torch.cuda.empty_cache()
utils/loggers/__init__.py CHANGED
@@ -131,7 +131,7 @@ class Loggers():
131
  if ((epoch + 1) % self.opt.save_period == 0 and not final_epoch) and self.opt.save_period != -1:
132
  self.wandb.log_model(last.parent, self.opt, epoch, fi, best_model=best_fitness == fi)
133
 
134
- def on_train_end(self, last, best, plots, epoch):
135
  # Callback runs on training end
136
  if plots:
137
  plot_results(file=self.save_dir / 'results.csv') # save results.png
 
131
  if ((epoch + 1) % self.opt.save_period == 0 and not final_epoch) and self.opt.save_period != -1:
132
  self.wandb.log_model(last.parent, self.opt, epoch, fi, best_model=best_fitness == fi)
133
 
134
+ def on_train_end(self, last, best, plots, epoch, results):
135
  # Callback runs on training end
136
  if plots:
137
  plot_results(file=self.save_dir / 'results.csv') # save results.png