Confused by <transform.ToTensor()> output

Ishan_Dahal: <p>Hello,<br>
I am a quite confused by the behavior of transforms.ToTensor()'s output.<br>
I am trying to visualize the output of the transform right before it is fed into the model and I see tilled output. The .ToTensor() is returning a tilled image after the transform. I manually transform the image and plotted the output. This is showing up different than than the output from ToTensor() transform. I have attached images of code with comments to illustrate the issue. Appreciate any info into the matter. <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=12" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"><br>
Thank you for you time and consideration. <a href="/uploads/short-url/qcHKsWoN5JlE0rbJmRkeUjrMMBA.png">Screen Shot 2021-03-12 at 7.07.07 AM|509x500</a> <div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/2/d/2dc60fcc4759b3e60e9d3169185b434472749502.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/2dc60fcc4759b3e60e9d3169185b434472749502" title="Screen Shot 2021-03-12 at 7.06.25 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/2/d/2dc60fcc4759b3e60e9d3169185b434472749502_2_503x500.jpeg" alt="Screen Shot 2021-03-12 at 7.06.25 AM" data-base62-sha1="6wVPy0HhYEbicSxuhSs5MkyAiYO" width="503" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/2/d/2dc60fcc4759b3e60e9d3169185b434472749502_2_503x500.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/2/d/2dc60fcc4759b3e60e9d3169185b434472749502_2_754x750.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/2/d/2dc60fcc4759b3e60e9d3169185b434472749502.jpeg 2x" data-dominant-color="DBDBDA"><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">Screen Shot 2021-03-12 at 7.06.25 AM</span><span class="informations">998×992 174 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>

Ishan_Dahal: <p>Follow on from above:<br>
This image shows the output of the manual scaling matches that of .ToTensor(). However the plots are different.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/b/7/b7a833dc7da1e1b19f5fe14661e066092e1a5caa.png" data-download-href="https://discuss.pytorch.org/uploads/default/b7a833dc7da1e1b19f5fe14661e066092e1a5caa" title="Screen Shot 2021-03-12 at 7.07.07 AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/b/7/b7a833dc7da1e1b19f5fe14661e066092e1a5caa_2_509x500.png" alt="Screen Shot 2021-03-12 at 7.07.07 AM" data-base62-sha1="qcHKsWoN5JlE0rbJmRkeUjrMMBA" width="509" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/b/7/b7a833dc7da1e1b19f5fe14661e066092e1a5caa_2_509x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/b/7/b7a833dc7da1e1b19f5fe14661e066092e1a5caa_2_763x750.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/b/7/b7a833dc7da1e1b19f5fe14661e066092e1a5caa_2_1018x1000.png 2x" data-dominant-color="E0E0DF"><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">Screen Shot 2021-03-12 at 7.07.07 AM</span><span class="informations">1118×1098 246 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>

Dwight_Foster: <p>Instead of doing .view you could try</p>
<pre><code class="lang-auto">tensor_image.permute(1,2,0)
</code></pre>
<p>sometimes .view can mess up the image.</p>

Ishan_Dahal: <p>That helped. Thanks! <a class="mention" href="/u/dwight_foster">@Dwight_Foster</a> <img src="https://discuss.pytorch.org/images/emoji/apple/pray.png?v=9" title=":pray:" class="emoji" alt=":pray:"> <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=9" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>