| 745 | |
| 746 | |
| 747 | class Resize(nn.Module): |
| 748 | def __init__(self, in_channels=None, learned=False, mode="bilinear"): |
| 749 | super().__init__() |
| 750 | self.with_conv = learned |
| 751 | self.mode = mode |
| 752 | if self.with_conv: |
| 753 | print(f"Note: {self.__class__.__name} uses learned downsampling and will ignore the fixed {mode} mode") |
| 754 | raise NotImplementedError() |
| 755 | assert in_channels is not None |
| 756 | # no asymmetric padding in torch conv, must do it ourselves |
| 757 | self.conv = torch.nn.Conv2d(in_channels, |
| 758 | in_channels, |
| 759 | kernel_size=4, |
| 760 | stride=2, |
| 761 | padding=1) |
| 762 | |
| 763 | def forward(self, x, scale_factor=1.0): |
| 764 | if scale_factor==1.0: |
| 765 | return x |
| 766 | else: |
| 767 | x = torch.nn.functional.interpolate(x, mode=self.mode, align_corners=False, scale_factor=scale_factor) |
| 768 | return x |
| 769 | |
| 770 | class FirstStagePostProcessor(nn.Module): |
| 771 |
nothing calls this directly
no outgoing calls
no test coverage detected