Ayush Chaurasia
commited on
W&B: fix refactor bugs (#4069)
Browse files- utils/wandb_logging/wandb_utils.py +4 -4
- val.py +1 -1
utils/wandb_logging/wandb_utils.py
CHANGED
@@ -106,6 +106,7 @@ class WandbLogger():
|
|
106 |
self.data_dict = data_dict
|
107 |
self.bbox_media_panel_images = []
|
108 |
self.val_table_path_map = None
|
|
|
109 |
# It's more elegant to stick to 1 wandb.init call, but useful config data is overwritten in the WandbLogger's wandb.init call
|
110 |
if isinstance(opt.resume, str): # checks resume from artifact
|
111 |
if opt.resume.startswith(WANDB_ARTIFACT_PREFIX):
|
@@ -133,7 +134,7 @@ class WandbLogger():
|
|
133 |
if not opt.resume:
|
134 |
wandb_data_dict = self.check_and_upload_dataset(opt) if opt.upload_dataset else data_dict
|
135 |
# Info useful for resuming from artifacts
|
136 |
-
self.wandb_run.config.update({'opt': vars(opt), 'data_dict':
|
137 |
self.data_dict = self.setup_training(opt, data_dict)
|
138 |
if self.job_type == 'Dataset Creation':
|
139 |
self.data_dict = self.check_and_upload_dataset(opt)
|
@@ -152,7 +153,7 @@ class WandbLogger():
|
|
152 |
return wandb_data_dict
|
153 |
|
154 |
def setup_training(self, opt, data_dict):
|
155 |
-
self.log_dict, self.current_epoch
|
156 |
self.bbox_interval = opt.bbox_interval
|
157 |
if isinstance(opt.resume, str):
|
158 |
modeldir, _ = self.download_model_artifact(opt)
|
@@ -317,8 +318,7 @@ class WandbLogger():
|
|
317 |
if self.val_table and self.result_table: # Log Table if Val dataset is uploaded as artifact
|
318 |
self.log_training_progress(predn, path, names)
|
319 |
else: # Default to bbox media panelif Val artifact not found
|
320 |
-
|
321 |
-
if len(self.bbox_media_panel_images) < log_imgs and self.current_epoch > 0:
|
322 |
if self.current_epoch % self.bbox_interval == 0:
|
323 |
box_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
|
324 |
"class_id": int(cls),
|
|
|
106 |
self.data_dict = data_dict
|
107 |
self.bbox_media_panel_images = []
|
108 |
self.val_table_path_map = None
|
109 |
+
self.max_imgs_to_log = 16
|
110 |
# It's more elegant to stick to 1 wandb.init call, but useful config data is overwritten in the WandbLogger's wandb.init call
|
111 |
if isinstance(opt.resume, str): # checks resume from artifact
|
112 |
if opt.resume.startswith(WANDB_ARTIFACT_PREFIX):
|
|
|
134 |
if not opt.resume:
|
135 |
wandb_data_dict = self.check_and_upload_dataset(opt) if opt.upload_dataset else data_dict
|
136 |
# Info useful for resuming from artifacts
|
137 |
+
self.wandb_run.config.update({'opt': vars(opt), 'data_dict': wandb_data_dict}, allow_val_change=True)
|
138 |
self.data_dict = self.setup_training(opt, data_dict)
|
139 |
if self.job_type == 'Dataset Creation':
|
140 |
self.data_dict = self.check_and_upload_dataset(opt)
|
|
|
153 |
return wandb_data_dict
|
154 |
|
155 |
def setup_training(self, opt, data_dict):
|
156 |
+
self.log_dict, self.current_epoch = {}, 0
|
157 |
self.bbox_interval = opt.bbox_interval
|
158 |
if isinstance(opt.resume, str):
|
159 |
modeldir, _ = self.download_model_artifact(opt)
|
|
|
318 |
if self.val_table and self.result_table: # Log Table if Val dataset is uploaded as artifact
|
319 |
self.log_training_progress(predn, path, names)
|
320 |
else: # Default to bbox media panelif Val artifact not found
|
321 |
+
if len(self.bbox_media_panel_images) < self.max_imgs_to_log and self.current_epoch > 0:
|
|
|
322 |
if self.current_epoch % self.bbox_interval == 0:
|
323 |
box_data = [{"position": {"minX": xyxy[0], "minY": xyxy[1], "maxX": xyxy[2], "maxY": xyxy[3]},
|
324 |
"class_id": int(cls),
|
val.py
CHANGED
@@ -215,7 +215,7 @@ def run(data,
|
|
215 |
save_one_txt(predn, save_conf, shape, file=save_dir / 'labels' / (path.stem + '.txt'))
|
216 |
if save_json:
|
217 |
save_one_json(predn, jdict, path, class_map) # append to COCO-JSON dictionary
|
218 |
-
if wandb_logger:
|
219 |
wandb_logger.val_one_image(pred, predn, path, names, img[si])
|
220 |
|
221 |
# Plot images
|
|
|
215 |
save_one_txt(predn, save_conf, shape, file=save_dir / 'labels' / (path.stem + '.txt'))
|
216 |
if save_json:
|
217 |
save_one_json(predn, jdict, path, class_map) # append to COCO-JSON dictionary
|
218 |
+
if wandb_logger and wandb_logger.wandb_run:
|
219 |
wandb_logger.val_one_image(pred, predn, path, names, img[si])
|
220 |
|
221 |
# Plot images
|