Skip to content

Commit

Permalink
Bugfix: use nrow in correct place when visualizing results (#102)
Browse files Browse the repository at this point in the history
Also normalize the result tensor when visulizaing it.
  • Loading branch information
shi-weili authored and avik-pal committed May 1, 2019
1 parent 9650398 commit 375b3df
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torchgan/logging/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def log_console(self, trainer, image, model):
"""
save_path = "{}/epoch{}_{}.png".format(trainer.recon, self.step, model)
print("Generating and Saving Images to {}".format(save_path))
torchvision.utils.save_image(image, save_path, nrow=self.nrow)
torchvision.utils.save_image(image, save_path)

def log_visdom(self, trainer, image, model):
r"""Logs a generated image in visdom at the end of an epoch.
Expand All @@ -472,7 +472,7 @@ def __call__(self, trainer, **kwargs):
generator = getattr(trainer, model)
with torch.no_grad():
image = generator(*self.test_noise[pos])
image = torchvision.utils.make_grid(image)
image = torchvision.utils.make_grid(image, nrow=self.nrow, normalize=True, range=(-1, 1))
super(ImageVisualize, self).__call__(
trainer, image, model, **kwargs
)
Expand Down

0 comments on commit 375b3df

Please sign in to comment.