MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / Resize

Class Resize

ldm/modules/diffusionmodules/model.py:840–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838
839
840class Resize(nn.Module):
841 def __init__(self, in_channels=None, learned=False, mode="bilinear"):
842 super().__init__()
843 self.with_conv = learned
844 self.mode = mode
845 if self.with_conv:
846 print(f"Note: {self.__class__.__name} uses learned downsampling and will ignore the fixed {mode} mode")
847 raise NotImplementedError()
848 assert in_channels is not None
849 # no asymmetric padding in torch conv, must do it ourselves
850 self.conv = torch.nn.Conv2d(in_channels,
851 in_channels,
852 kernel_size=4,
853 stride=2,
854 padding=1)
855
856 def forward(self, x, scale_factor=1.0):
857 if scale_factor==1.0:
858 return x
859 else:
860 x = torch.nn.functional.interpolate(x, mode=self.mode, align_corners=False, scale_factor=scale_factor)
861 return x

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected