ESRGAN icon indicating copy to clipboard operation
ESRGAN copied to clipboard

UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead

Open Zengpr opened this issue 5 years ago • 5 comments

I have the problem: Model path models/RRDB_ESRGAN_x4.pth. Testing... 1 baboon /usr/local/lib/python3.6/dist-packages/torch/nn/modules/upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.{} is deprecated. Use nn.functional.interpolate instead.".format(self.name)) 2 comic

Zengpr avatar Jan 15 '19 02:01 Zengpr

This is not a problem, it is just a warning. Because pytorch has changed the interface and nn.Upsample is deprecated.

xinntao avatar Jan 17 '19 07:01 xinntao

I get the same issue but my process gets killed.

/home/carlos/.local/lib/python3.6/site-packages/torch/nn/modules/upsampling.py:129: UserWarning: nn.Upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.{} is deprecated. Use nn.functional.interpolate instead.".format(self.name)) Killed

Hedronmx avatar Feb 13 '19 00:02 Hedronmx

@Hedronmx I think this warning will not kill the program...

You can replace the nn.Upsample to nn.functional.interpolate. You need to re-write the structure, because the whole model is in a nn.Sequential now and nn.functional.interpolate should be used in the forward function.

xinntao avatar Feb 14 '19 16:02 xinntao

You could implement yourself:

class Interpolate(nn.Module):
    def __init__(self, scale_factor, mode):
        super(Interpolate, self).__init__()
        self.interp = nn.functional.interpolate
        self.scale_factor = scale_factor
        self.mode = mode
        
    def forward(self, x):
        x = self.interp(x, scale_factor=self.scale_factor, mode=self.mode)
        return x

Then assign it: upsample = Interpolate(scale_factor=upscale_factor, mode=mode)

@young666 Thanks. We are now updating a new version for ESRGAN testing codes and BasicSR repo and we will fix it.

xinntao avatar Jun 01 '19 13:06 xinntao