Janspiry / Image-Super-Resolution-via-Iterative-Refinement

Unofficial implementation of Image Super-Resolution via Iterative Refinement by Pytorch
Apache License 2.0
3.6k stars 469 forks source link

Bug in the data augmentation code #125

Closed Morefre closed 1 year ago

Morefre commented 1 year ago
          Hi @Janspiry , 

In continue to my comment @ErezYosef https://github.com/Janspiry/Image-Super-Resolution-via-Iterative-Refinement/issues/14#issuecomment-918394583

I think its better to use the dedicated torchvision functions instead of implement them.

My Suggested implementation:

    totensor = torchvision.transforms.ToTensor()
    hflip = torchvision.transforms.RandomHorizontalFlip()
    imgs = [totensor(img) for img in img_list]
    if split == 'train':
        imgs = torch.stack(imgs, 0)
        imgs = hflip(imgs)
        imgs = torch.unbind(imgs, dim=0)
    ret_img = [img * (min_max[1] - min_max[0]) + min_max[0] for img in imgs]

Originally posted by @ErezYosef in https://github.com/Janspiry/Image-Super-Resolution-via-Iterative-Refinement/issues/14#issuecomment-918503497

This code is incorrect because it randomly flips every image independently, as shown in the figures below: image image