GAN generated image is correct but too light

pytorchnewbie: <p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/8/8aaf77b90d24d13417d9bff4487859aa00ff5181.png" data-download-href="https://discuss.pytorch.org/uploads/default/8aaf77b90d24d13417d9bff4487859aa00ff5181" title="40%20PM"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/8/8aaf77b90d24d13417d9bff4487859aa00ff5181_2_690x273.png" alt="40%20PM" data-base62-sha1="jMRPnod9CYnL4jsSWPpWRZuCEY9" width="690" height="273" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/8/8aaf77b90d24d13417d9bff4487859aa00ff5181_2_690x273.png, https://discuss.pytorch.org/uploads/default/optimized/2X/8/8aaf77b90d24d13417d9bff4487859aa00ff5181_2_1035x409.png 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/8/8aaf77b90d24d13417d9bff4487859aa00ff5181.png 2x" data-dominant-color="908D92"><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">40%20PM</span><span class="informations">1112×440 262 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>
I’ve been trying to use cyclegan for image inpainting, passing in real A (which has a small black mask in the bottom right corner for the second example), getting the result fake B, and the ground truth being real B. I also generate fake A, which is what is generated by passing in Fake B into the reverse generator, and it is also too light, but didnt show it here to not complicate this post. The point is that both images synthesized by the generator seem to be a shade too light and I’ve experimented with other datasets/other tasks with cyclegan and this pattern is consistent. Anyone have any idea what could be happening?</p>
<p>The last layer is tanh so range -1 to 1, so I add 1, divide by 2, and multiply by 255 to get it into the correct range. I also make sure to normalize the input image for my losses, and I do this by normalizing their range to -1 to 1, so that the output of the generator and the input image’s losses are correct.</p>

Xin_Perry: <p>i think you should check the input of the tanh layer first.<br>
I guess they are (nearly) all postive , so the output pixels of you generator  ranges from 0 to 1 (rather than -1 to 1), after you denorm them , the synthesized img ranges from 127 to 255 ( equal to add 127 to origin img  ), so the result seems lighter than the GT.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/0/0ec6eafec2309565a68a5d3050ed295ff4b9aa24.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/0ec6eafec2309565a68a5d3050ed295ff4b9aa24" title="image"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/0/0ec6eafec2309565a68a5d3050ed295ff4b9aa24_2_690x335.jpeg" alt="image" data-base62-sha1="26IRAtCjH2DHgUltZaCUcq7Dggc" width="690" height="335" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/0/0ec6eafec2309565a68a5d3050ed295ff4b9aa24_2_690x335.jpeg, https://discuss.pytorch.org/uploads/default/optimized/2X/0/0ec6eafec2309565a68a5d3050ed295ff4b9aa24_2_1035x502.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/0/0ec6eafec2309565a68a5d3050ed295ff4b9aa24.jpeg 2x" data-dominant-color="BAB1A6"><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">image</span><span class="informations">1114×542 124 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>

pytorchnewbie: <p>That makes perfect sense thank you but unfortunately I don’t think that is the case because I checked the max and min values of the outputed fake_A and fake_B generated before I denormalized  (changing range from -1 to 1 to 0 to 255, attached screenshot of function called convert_from_tanh), and the values of the generated image’s max and min are indeed -.99 to .99 so it seems like the range is correct?<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/7/7ff9ee5ec0a1b9bc12a27d0a5d01c3a5f54b0434.png" data-download-href="https://discuss.pytorch.org/uploads/default/7ff9ee5ec0a1b9bc12a27d0a5d01c3a5f54b0434" title="55%20AM"><img src="https://discuss.pytorch.org/uploads/default/original/2X/7/7ff9ee5ec0a1b9bc12a27d0a5d01c3a5f54b0434.png" alt="55%20AM" data-base62-sha1="ig873baW0ya0WiGvpdU9Kfx21Fy" width="690" height="217" data-dominant-color="F0E7D5"><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">55%20AM</span><span class="informations">750×236 26.8 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/2X/d/d2f36fa91ac0897d2f92b3778e7c448f52721af2.png" data-download-href="https://discuss.pytorch.org/uploads/default/d2f36fa91ac0897d2f92b3778e7c448f52721af2" title="32%20AM"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/d/d2f36fa91ac0897d2f92b3778e7c448f52721af2_2_690x203.png" alt="32%20AM" data-base62-sha1="u69PmkYsVpRLisUJHQavU2pPLNw" width="690" height="203" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/d/d2f36fa91ac0897d2f92b3778e7c448f52721af2_2_690x203.png, https://discuss.pytorch.org/uploads/default/optimized/2X/d/d2f36fa91ac0897d2f92b3778e7c448f52721af2_2_1035x304.png 1.5x, https://discuss.pytorch.org/uploads/default/original/2X/d/d2f36fa91ac0897d2f92b3778e7c448f52721af2.png 2x" data-dominant-color="232832"><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">32%20AM</span><span class="informations">1046×308 144 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>

HudPesjan: <p>Hi! I’m experiencing the same issue and the range also seems to be okay, so I’m curious whether you have figured anything out in the meantime?</p>