Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
- fixed image normalization in tensorboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nasimrahaman committed Jun 19, 2018
1 parent c70aee0 commit e22deee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions inferno/trainers/callbacks/logging/tensorboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,15 @@ def log_images(self, tag, images, step, image_format='CHW'):
# tensorboardX borks if the number of image channels is not 3
if image.shape[-1] == 1:
image = image[..., [0, 0, 0]]
image = self._normalize_image(image)
self.writer.add_image(tag, img_tensor=image, global_step=step)

@staticmethod
def _normalize_image(image):
normalized_image = image - image.min()
normalized_image = normalized_image / normalized_image.max()
return normalized_image

def log_histogram(self, tag, values, step, bins=1000):
"""Logs the histogram of a list/vector of values."""
# TODO
Expand Down

0 comments on commit e22deee

Please sign in to comment.