Thanks for the code and link to the notebook.
It seems that ToPILImage is creating the different output, as you are passing a FloatTensor, which is assumed to be in the range [0, 1], while yours has the range [0, 255].
This line of code 14 will most likely overflow and thus creating the “edge”-like image.
Since the edges have smaller values than the center of the letter, the center values will more likely overflow, thus creating small output values.
To fix it, you should transform the image to byte() and call transform on it:
transform_Image = transform(image.byte())