In line 51, that is:
clip = lambda x: clip_tensor(x, 0, 255)
should be:
clip = lambda x: clip_tensor(x, 0, 1)
In tf, transforms.Lambda() is in front, and there is no multiplication by 255 which will be operated by transforms.ToPILImage() .
But this should not affect the final result.