Skip to content

Commit 65a3087

Browse files
authored
Log best results (ultralytics#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
1 parent 4e1a98d commit 65a3087

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

utils/loggers/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(self, save_dir=None, weights=None, opt=None, hyp=None, logger=None,
4747
'metrics/precision', 'metrics/recall', 'metrics/mAP_0.5', 'metrics/mAP_0.5:0.95', # metrics
4848
'val/box_loss', 'val/obj_loss', 'val/cls_loss', # val loss
4949
'x/lr0', 'x/lr1', 'x/lr2'] # params
50+
self.best_keys = ['best/epoch', 'best/precision', 'best/recall', 'best/mAP_0.5', 'best/mAP_0.5:0.95',]
5051
for k in LOGGERS:
5152
setattr(self, k, None) # init empty logger dictionary
5253
self.csv = True # always log to csv
@@ -125,6 +126,10 @@ def on_fit_epoch_end(self, vals, epoch, best_fitness, fi):
125126
self.tb.add_scalar(k, v, epoch)
126127

127128
if self.wandb:
129+
if best_fitness == fi:
130+
best_results = [epoch] + vals[3:7]
131+
for i, name in enumerate(self.best_keys):
132+
self.wandb.wandb_run.summary[name] = best_results[i] # log best results in the summary
128133
self.wandb.log(x)
129134
self.wandb.end_epoch(best_result=best_fitness == fi)
130135

0 commit comments

Comments
 (0)