Skip to content

Commit ba4fbf6

Browse files
committed
log more than 1 image
1 parent 5f543e6 commit ba4fbf6

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

yolo/utils/callbacks/tensorboard_plotter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ def _dump_measures(train_dpath, title='?name?', smoothing='auto', ignore_outlier
273273
plot_preferences.update(user_plot_preferences)
274274
else:
275275
plot_preferences = default_plot_preferences
276-
print(f'plot_preferences = {ub.urepr(plot_preferences, nl=3)}')
277276

278277
for item in plot_preferences['attributes']:
279278
item['pattern_'] = kwutil.util_pattern.MultiPattern.coerce(item['pattern'])

yolo/utils/logging_utils.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,19 @@ def on_validation_batch_end(self, trainer: Trainer, pl_module, outputs, batch, b
213213
if batch_idx != 0:
214214
return
215215
batch_size, images, targets, rev_tensor, img_paths = batch
216-
gt_boxes = targets[0] if targets.ndim == 3 else targets
217-
pred_boxes = outputs[0] if isinstance(outputs, list) else outputs
218-
images = [images[0]]
216+
# gt_boxes = targets[0] if targets.ndim == 3 else targets
217+
# pred_boxes = outputs[0] if isinstance(outputs, list) else outputs
218+
# images = images[:]
219219
step = trainer.current_epoch
220220

221-
for logger in trainer.loggers:
222-
if isinstance(logger, WandbLogger):
221+
for _logger in trainer.loggers:
222+
if isinstance(_logger, WandbLogger):
223223
# FIXME: not robust to configured image sizes, need to know
224224
# that info.
225-
logger.log_image("Input Image", images, step=step)
226-
logger.log_image("Ground Truth", images, step=step, boxes=[log_bbox(gt_boxes)])
227-
logger.log_image("Prediction", images, step=step, boxes=[log_bbox(pred_boxes)])
225+
for image, gt_boxes, pred_boxes in zip(images, targets, outputs):
226+
_logger.log_image("Input Image", [image], step=step)
227+
_logger.log_image("Ground Truth", [image], step=step, boxes=[log_bbox(gt_boxes)])
228+
_logger.log_image("Prediction", [image], step=step, boxes=[log_bbox(pred_boxes)])
228229

229230
# TODO: better config
230231
import os
@@ -243,6 +244,8 @@ def on_validation_batch_end(self, trainer: Trainer, pl_module, outputs, batch, b
243244

244245
for bx in range(len(images)):
245246
image_chw = images[bx].data.cpu().numpy()
247+
gt_boxes = targets[bx]
248+
pred_boxes = outputs[bx]
246249
image_hwc = einops.rearrange(image_chw, 'c h w -> h w c')
247250
image_hwc = kwimage.ensure_uint255(image_hwc)
248251

0 commit comments

Comments
 (0)