MCPcopy Create free account
hub / github.com/IceClear/StableSR / __init__

Method __init__

ldm/modules/diffusionmodules/model.py:121–157  ·  view source on GitHub ↗
(self, *, in_channels, out_channels=None, conv_shortcut=False,
                 dropout, temb_channels=512)

Source from the content-addressed store, hash-verified

119
120class ResnetBlock(nn.Module):
121 def __init__(self, *, in_channels, out_channels=None, conv_shortcut=False,
122 dropout, temb_channels=512):
123 super().__init__()
124 self.in_channels = in_channels
125 out_channels = in_channels if out_channels is None else out_channels
126 self.out_channels = out_channels
127 self.use_conv_shortcut = conv_shortcut
128
129 self.norm1 = Normalize(in_channels)
130 self.conv1 = torch.nn.Conv2d(in_channels,
131 out_channels,
132 kernel_size=3,
133 stride=1,
134 padding=1)
135 if temb_channels > 0:
136 self.temb_proj = torch.nn.Linear(temb_channels,
137 out_channels)
138 self.norm2 = Normalize(out_channels)
139 self.dropout = torch.nn.Dropout(dropout)
140 self.conv2 = torch.nn.Conv2d(out_channels,
141 out_channels,
142 kernel_size=3,
143 stride=1,
144 padding=1)
145 if self.in_channels != self.out_channels:
146 if self.use_conv_shortcut:
147 self.conv_shortcut = torch.nn.Conv2d(in_channels,
148 out_channels,
149 kernel_size=3,
150 stride=1,
151 padding=1)
152 else:
153 self.nin_shortcut = torch.nn.Conv2d(in_channels,
154 out_channels,
155 kernel_size=1,
156 stride=1,
157 padding=0)
158
159 def forward(self, x, temb):
160 h = x

Callers

nothing calls this directly

Calls 2

NormalizeFunction · 0.70
__init__Method · 0.45

Tested by

no test coverage detected