This equation is exactly copied from the website below: https://clouard.users.greyc.fr/Pantheon/experiments/rescaling/index-en.html#bicubic
(self, x, a=-0.50)
| 5 | |
| 6 | class BicubicDownSample(nn.Module): |
| 7 | def bicubic_kernel(self, x, a=-0.50): |
| 8 | """ |
| 9 | This equation is exactly copied from the website below: |
| 10 | https://clouard.users.greyc.fr/Pantheon/experiments/rescaling/index-en.html#bicubic |
| 11 | """ |
| 12 | abs_x = torch.abs(x) |
| 13 | if abs_x <= 1.: |
| 14 | return (a + 2.) * torch.pow(abs_x, 3.) - (a + 3.) * torch.pow(abs_x, 2.) + 1 |
| 15 | elif 1. < abs_x < 2.: |
| 16 | return a * torch.pow(abs_x, 3) - 5. * a * torch.pow(abs_x, 2.) + 8. * a * abs_x - 4. * a |
| 17 | else: |
| 18 | return 0.0 |
| 19 | |
| 20 | def __init__(self, factor=4, cuda=True, padding='reflect'): |
| 21 | super().__init__() |