MCPcopy Create free account
hub / github.com/ShanghaiTech-IMPACT/TeethDreamer / Downsample

Class Downsample

ldm/modules/diffusionmodules/model.py:60–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class Downsample(nn.Module):
61 def __init__(self, in_channels, with_conv):
62 super().__init__()
63 self.with_conv = with_conv
64 if self.with_conv:
65 # no asymmetric padding in torch conv, must do it ourselves
66 self.conv = torch.nn.Conv2d(in_channels,
67 in_channels,
68 kernel_size=3,
69 stride=2,
70 padding=0)
71
72 def forward(self, x):
73 if self.with_conv:
74 pad = (0,1,0,1)
75 x = torch.nn.functional.pad(x, pad, mode="constant", value=0)
76 x = self.conv(x)
77 else:
78 x = torch.nn.functional.avg_pool2d(x, kernel_size=2, stride=2)
79 return x
80
81
82class ResnetBlock(nn.Module):

Callers 3

__init__Method · 0.70
__init__Method · 0.70
__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected