From 7b6938d5b54f562e6883eb294b4904066bef8188 Mon Sep 17 00:00:00 2001 From: Awsaf Date: Fri, 31 Dec 2021 03:47:53 +0600 Subject: [PATCH] Log best results (#6085) * log best result in summary * comment added * add space for `flake8` * log `best/epoch` * fix `dimension` for epoch ValueError: all the input arrays must have same number of dimensions * log `best/` in `utils.logger.__init__` * fix pre-commit 1. missing whitespace around operator 2. over-indented --- utils/loggers/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 8af5c402d5ee..7679ee70f176 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -47,6 +47,7 @@ def __init__(self, save_dir=None, weights=None, opt=None, hyp=None, logger=None, 'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95', # metrics 'val/box_loss', 'val/obj_loss', 'val/cls_loss', # val loss 'x/lr0', 'x/lr1', 'x/lr2'] # params + self.best_keys = ['best/epoch', 'best/precision', 'best/recall', 'best/mAP_0.5', 'best/mAP_0.5:0.95',] for k in LOGGERS: setattr(self, k, None) # init empty logger dictionary self.csv = True # always log to csv @@ -125,6 +126,10 @@ def on_fit_epoch_end(self, vals, epoch, best_fitness, fi): self.tb.add_scalar(k, v, epoch) if self.wandb: + if best_fitness == fi: + best_results = [epoch] + vals[3:7] + for i, name in enumerate(self.best_keys): + self.wandb.wandb_run.summary[name] = best_results[i] # log best results in the summary self.wandb.log(x) self.wandb.end_epoch(best_result=best_fitness == fi)