From 0cc7c587870f31f0fc175a74048ceca616870aea Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Mon, 19 Jul 2021 17:27:13 +0530 Subject: [PATCH] W&B: fix refactor bugs (#4069) --- utils/wandb_logging/wandb_utils.py | 8 ++++---- val.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/wandb_logging/wandb_utils.py b/utils/wandb_logging/wandb_utils.py index a7e84ca100e4..03f2d151bdc3 100644 --- a/utils/wandb_logging/wandb_utils.py +++ b/utils/wandb_logging/wandb_utils.py @@ -106,6 +106,7 @@ def __init__(self, opt, name, run_id, data_dict, job_type='Training'): self.data_dict = data_dict self.bbox_media_panel_images = [] self.val_table_path_map = None + self.max_imgs_to_log = 16 # It's more elegant to stick to 1 wandb.init call, but useful config data is overwritten in the WandbLogger's wandb.init call if isinstance(opt.resume, str): # checks resume from artifact if opt.resume.startswith(WANDB_ARTIFACT_PREFIX): @@ -133,7 +134,7 @@ def __init__(self, opt, name, run_id, data_dict, job_type='Training'): if not opt.resume: wandb_data_dict = self.check_and_upload_dataset(opt) if opt.upload_dataset else data_dict # Info useful for resuming from artifacts - self.wandb_run.config.update({'opt': vars(opt), 'data_dict': data_dict}, allow_val_change=True) + self.wandb_run.config.update({'opt': vars(opt), 'data_dict': wandb_data_dict}, allow_val_change=True) self.data_dict = self.setup_training(opt, data_dict) if self.job_type == 'Dataset Creation': self.data_dict = self.check_and_upload_dataset(opt) @@ -152,7 +153,7 @@ def check_and_upload_dataset(self, opt): return wandb_data_dict def setup_training(self, opt, data_dict): - self.log_dict, self.current_epoch, self.log_imgs = {}, 0, 16 # Logging Constants + self.log_dict, self.current_epoch = {}, 0 self.bbox_interval = opt.bbox_interval if isinstance(opt.resume, str): modeldir, _ = self.download_model_artifact(opt) @@ -317,8 +318,7 @@ def val_one_image(self, pred, predn, path, names, im): if self.val_table and self.result_table: # Log Table if Val dataset is uploaded as artifact self.log_training_progress(predn, path, names) else: # Default to bbox media panelif Val artifact not found - log_imgs = min(self.log_imgs, 100) - if len(self.bbox_media_panel_images) < log_imgs and self.current_epoch > 0: + if len(self.bbox_media_panel_images) < self.max_imgs_to_log and self.current_epoch > 0: if self.current_epoch % self.bbox_interval == 0: box_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]}, "class_id": int(cls), diff --git a/val.py b/val.py index 5a8486720577..e493dfe66ae8 100644 --- a/val.py +++ b/val.py @@ -215,7 +215,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: + if wandb_logger and wandb_logger.wandb_run: wandb_logger.val_one_image(pred, predn, path, names, img[si]) # Plot images