JuliaWolleb / DeScarGAN

Official Pytorch implementation of the paper DeScarGAN
Apache License 2.0
30 stars 5 forks source link

Cannot find the definition of RandomWarpDeformer() #2

Closed QQR1 closed 3 years ago

QQR1 commented 4 years ago

Hi, here have a question about the DeScarGAN. In utils/tooIs.py, I cannot find the definition of RandomWarpDeformer() (Line 155

`class RandomWarpTransform(): """Transforms an image by warping it smoothly.

The transform is defined by moving four points within the image by a random amount. The displacement of the
intermediate points is interpolated using polynomial interpolation. The displacement vanishes at the boundary
of the image.

Can be used just like torchvision.transforms
"""

def __init__(self):
    self.rwd = RandomWarpDeformer()
    # self.rwd = RandomWarpTransform()

def __call__(self, img):
    """Takes PIL Image and performs random warp.
    """
    C = np.array(img)
    print('C=', C.shape)
    img2 = PIL.ImageOps.deform(img, self.rwd, resample=PIL.Image.BILINEAR)
    return img2

def __repr__(self):
    return "TransposeRandomWarpTransform.__repr__() not implemented"`
JuliaWolleb commented 4 years ago

Hi

The definition of RandomWarpDeformer() was missing, I added it to the file utils/tools.py. Thanks for pointing it out.

However, we'd like to point out that RandomWarpTransform() is not used during data augmentation. I'm sorry for the confusion, this class was only used in an outdated version, and I left it in the code for completeness.