MCPcopy
hub / github.com/lllyasviel/Paints-UNDO / EncoderDownSampleBlock

Class EncoderDownSampleBlock

diffusers_vdm/vae.py:70–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70class EncoderDownSampleBlock(nn.Module):
71 def __init__(self, in_channels, with_conv):
72 super().__init__()
73 self.with_conv = with_conv
74 self.in_channels = in_channels
75 if self.with_conv:
76 self.conv = torch.nn.Conv2d(in_channels,
77 in_channels,
78 kernel_size=3,
79 stride=2,
80 padding=0)
81
82 def forward(self, x):
83 if self.with_conv:
84 pad = (0, 1, 0, 1)
85 x = torch.nn.functional.pad(x, pad, mode="constant", value=0)
86 x = self.conv(x)
87 else:
88 x = torch.nn.functional.avg_pool2d(x, kernel_size=2, stride=2)
89 return x
90
91
92class ResnetBlock(nn.Module):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected