Transform affecting my Images

bolt25: <p>Im working on fringe pattern denoising and in that I have fringe patterns like:-<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/4/b4f177e003ce9a752dd57ef109872d439493f832.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/b4f177e003ce9a752dd57ef109872d439493f832" title="Screenshot from 2020-06-18 16-43-39"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/4/b4f177e003ce9a752dd57ef109872d439493f832_2_690x387.jpeg" alt="Screenshot from 2020-06-18 16-43-39" data-base62-sha1="pOHhRfrKCeVHMPx6UXcJmMzX9zY" width="690" height="387" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/4/b4f177e003ce9a752dd57ef109872d439493f832_2_690x387.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/b/4/b4f177e003ce9a752dd57ef109872d439493f832_2_1035x580.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/b/4/b4f177e003ce9a752dd57ef109872d439493f832.jpeg 2x" data-dominant-color="565656"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot from 2020-06-18 16-43-39</span><span class="informations">1366×768 189 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>but when I apply the transform of ToTensor()</p>
<p>and then print the image, it turns so bad that my model isn’t learning anything:-<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/a/6/a62bcd8022392657d6ffe502e04a8fa593e2b404.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/a62bcd8022392657d6ffe502e04a8fa593e2b404" title="Screenshot from 2020-06-18 16-45-37"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62bcd8022392657d6ffe502e04a8fa593e2b404_2_690x387.jpeg" alt="Screenshot from 2020-06-18 16-45-37" data-base62-sha1="nI16DoVSZfldKlGr50N8ZBrAcf2" width="690" height="387" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62bcd8022392657d6ffe502e04a8fa593e2b404_2_690x387.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/a/6/a62bcd8022392657d6ffe502e04a8fa593e2b404_2_1035x580.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/a/6/a62bcd8022392657d6ffe502e04a8fa593e2b404.jpeg 2x" data-dominant-color="575656"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">Screenshot from 2020-06-18 16-45-37</span><span class="informations">1366×768 327 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>any suggestions on what can I do?<br>
Because I dont think that its possible train my model on the images without converting them into tensors?</p>

Nikronic: <p>Hi,</p>
<p>Can you share one of the images in your dataset and also the method to visualize transformed images?</p>
<p>It would be great also if you could combine your questions into single topic as they are highly correlated.</p><aside class="quote" data-post="1" data-topic="85935">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bolt25/48/7273_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/normalisation-necessary-for-image-reconstruction/85935/1">Normalisation necessary for image reconstruction?</a> <a class="badge-category__wrapper " href="/c/vision/5"><span data-category-id="5" data-drop-close="true" class="badge-category " title="Topics related to either pytorch/vision or vision research related topics"><span class="badge-category__name">vision</span></span></a>
  </div>
  <blockquote>
    I have a dataset which needs to be denoised. When I was looking at the images of my dataloader which are fed into network I saw that the images from dataloader and images in my dataset are very different. Now the only transformation I used are resize and ToTensor(). 
Is it because of ToTensor()? Is it normalizing my image and is that causing my model to learn nothing? 
Can I stop this?
  </blockquote>
</aside>

<p>Bests</p>

bolt25: <p>The above image is from dataset and the below image is after transform in the image mention in the above question.</p>

Nikronic: <p>I meant the original image file so I can test a few things.<br>
Also, I think the way you visualize your data is not correct, that is why I am asking the method of visualization for your transformed data.</p>

bolt25: <pre><code class="lang-auto">def dispImageFromModel(tensor):
    img = tensor.cpu().detach().numpy()
    img = img.reshape((512,512))
    img, cb, cr = Image.fromarray(img, 'YCbCr').split()
    return img
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/0/9/090bfadfabc1f70f1550e4b5bf9f0dd199a20158.png" data-download-href="https://discuss.pytorch.org/uploads/default/090bfadfabc1f70f1550e4b5bf9f0dd199a20158" title="cleanImage#0"><img src="https://discuss.pytorch.org/uploads/default/original/3X/0/9/090bfadfabc1f70f1550e4b5bf9f0dd199a20158.png" alt="cleanImage#0" data-base62-sha1="1i1XMqYc0iimwvhvl18KEBhWvpK" width="666" height="500" data-dominant-color="858585"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">cleanImage#0</span><span class="informations">1200×900 112 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/5/5/556cc762646f4c3cf1c8e2a54a08be2a324252ca.png" data-download-href="https://discuss.pytorch.org/uploads/default/556cc762646f4c3cf1c8e2a54a08be2a324252ca" title="noisyImage#0"><img src="https://discuss.pytorch.org/uploads/default/original/3X/5/5/556cc762646f4c3cf1c8e2a54a08be2a324252ca.png" alt="noisyImage#0" data-base62-sha1="cbHDQ6W6wkFb8E7pYb4hEnYznSi" width="666" height="500" data-dominant-color="242424"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">noisyImage#0</span><span class="informations">1200×900 256 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

bolt25: <p>For anyone who is looking for answers!<br>
Follow the below link!</p>
<aside class="quote" data-post="5" data-topic="85935">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/bolt25/48/7273_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/normalisation-necessary-for-image-reconstruction/85935/5">Normalisation necessary for image reconstruction?</a> <a class="badge-category__wrapper " href="/c/vision/5"><span data-category-id="5" data-drop-close="true" class="badge-category " title="Topics related to either pytorch/vision or vision research related topics"><span class="badge-category__name">vision</span></span></a>
  </div>
  <blockquote>
    Thank you so so much!! This worked like a charm!!
  </blockquote>
</aside>

<p>Thank you! <a class="mention" href="/u/nikronic">@Nikronic</a></p>