From c21d7cab57c3f24f9c88bd1fd135f90e2ca60fd5 Mon Sep 17 00:00:00 2001 From: Varuna Jayasiri Date: Wed, 28 Oct 2020 09:23:35 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20normalize=20images=20in=20sample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labml_nn/gan/cycle_gan.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/labml_nn/gan/cycle_gan.py b/labml_nn/gan/cycle_gan.py index 437aa6e6..51095879 100644 --- a/labml_nn/gan/cycle_gan.py +++ b/labml_nn/gan/cycle_gan.py @@ -692,6 +692,10 @@ def sample(): data = x_image.unsqueeze(0).to(conf.device) generated_y = conf.generator_xy(data) + # Normalize the image + mm_range = generated_y.min(), generated_y.max() + generated_y = (generated_y - mm_range[0]) / (mm_range[1] - mm_range[0] + 1e-5) + # Display the generated image. We have to change the order of dimensions to HWC. plt.imshow(generated_y[0].cpu().permute(1, 2, 0)) plt.show()