eriklindernoren / PyTorch-GAN

PyTorch implementations of Generative Adversarial Networks.
MIT License
16.17k stars 4.05k forks source link

ESRGAN datasets.py problem #198

Open lizhuoq opened 1 year ago

lizhuoq commented 1 year ago

In the denormalize function, the range for clamping the tensor should be between 0 and 1. This is because the input tensors to the function include one tensor processed by the ToTensor function and another tensor generated by the network. The valid value range for both of these tensors is between 0 and 1. Therefore, the denormalize function should be modified accordingl. Modify it as follows:

def denormalize(tensors):
    ''' channel in the second dim'''
    for c in range(3):
        tensors[:, c].mul_(std[c]).add_(mean[c]) # Underscores are in-place operations
    return torch.clamp(tensors, 0, 1)