Refactor train.py and val.py loggers (#4137)

* Update loggers

* Config

* Update val.py

* cleanup

* fix1

* fix2

* fix3 and reformat

* format sweep.py

* Logger() class

* cleanup

* cleanup2

* wandb package import fix

* wandb package import fix2

* txt fix

* fix4

* fix5

* fix6

* drop wandb into utils/loggers

* fix 7

* rename loggers/wandb_logging to loggers/wandb

* Update message

* Update message

* Update message

* cleanup

* Fix x axis bug

* fix rank 0 issue

* cleanup
This commit is contained in:
Glenn Jocher authored and GitHub committed 2021-07-25 01:18:39 +02:00
1 parent 63dd65e7ed
commit efe60b5681
9 files changed
+172 -91

No files matched your search

+4 -6
View File
@@ -26,6 +26,7 @@ from utils.general import coco80_to_coco91_class, check_dataset, check_file, che
from utils.metrics import ap_per_class, ConfusionMatrix
from utils.plots import plot_images, output_to_target, plot_study_txt
from utils.torch_utils import select_device, time_sync
from utils.loggers import Loggers
def save_one_txt(predn, save_conf, shape, file):
@@ -97,7 +98,7 @@ def run(data,
dataloader=None,
save_dir=Path(''),
plots=True,
wandb_logger=None,
loggers=Loggers(),
compute_loss=None,
):
# Initialize/load model and set device
@@ -215,8 +216,7 @@ def run(data,
save_one_txt(predn, save_conf, shape, file=save_dir / 'labels' / (path.stem + '.txt'))
if save_json:
save_one_json(predn, jdict, path, class_map) # append to COCO-JSON dictionary
if wandb_logger and wandb_logger.wandb_run:
wandb_logger.val_one_image(pred, predn, path, names, img[si])
loggers.on_val_batch_end(pred, predn, path, names, img[si])
# Plot images
if plots and batch_i < 3:
@@ -253,9 +253,7 @@ def run(data,
# Plots
if plots:
confusion_matrix.plot(save_dir=save_dir, names=list(names.values()))
if wandb_logger and wandb_logger.wandb:
val_batches = [wandb_logger.wandb.Image(str(f), caption=f.name) for f in sorted(save_dir.glob('val*.jpg'))]
wandb_logger.log({"Validation": val_batches})
loggers.on_val_end()
# Save JSON
if save_json and len(jdict):