PyTorch-CycleGAN icon indicating copy to clipboard operation
PyTorch-CycleGAN copied to clipboard

about results

Open YeHuanjie opened this issue 5 years ago • 2 comments
trafficstars

my test images have Artifacts like this, what's the problem and how to sovle it? thx anyway! 1

YeHuanjie avatar May 21 '20 05:05 YeHuanjie

I also have this problem, how did you solve it.

751994772 avatar Aug 09 '21 11:08 751994772

this is a bug widely spreaded in GAN like networks. when you do upsampling, you should not use deconvolution/transposed/ any similar networks. You should use resize convolution/ Upsample networks. check this paper: https://distill.pub/2016/deconv-checkerboard/ #Checkerboard #Artifacts

some code for beginners:

class UpBlock(nn.Module):
    def __init__(self, in_channels, out_channels):
        super(UpBlock, self).__init__()
        # Replace upconv with an interpolation followed by a convolution.
        self.upsample = nn.Upsample(scale_factor=2, mode='bilinear')  # You can also try mode='bilinear'
        self.conv = nn.Conv2d(in_channels, in_channels // 2, kernel_size=3, padding=1)
        self.conv_block = ConvBlock(in_channels // 2 + in_channels // 2, out_channels)  # Adjust for the concatenated channels

    def forward(self, x, skip):
        x = self.upsample(x)
        x = self.conv(x)
        x = torch.cat([x, skip], dim=1)
        return self.conv_block(x)

xycjscs avatar Dec 26 '23 15:12 xycjscs