MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / __init__

Method __init__

diffusers/src/diffusers/models/resnet.py:220–318  ·  view source on GitHub ↗
(
        self,
        *,
        in_channels: int,
        out_channels: Optional[int] = None,
        conv_shortcut: bool = False,
        dropout: float = 0.0,
        temb_channels: int = 512,
        groups: int = 32,
        groups_out: Optional[int] = None,
        pre_norm: bool = True,
        eps: float = 1e-6,
        non_linearity: str = "swish",
        skip_time_act: bool = False,
        time_embedding_norm: str = "default",  # default, scale_shift,
        kernel: Optional[torch.Tensor] = None,
        output_scale_factor: float = 1.0,
        use_in_shortcut: Optional[bool] = None,
        up: bool = False,
        down: bool = False,
        conv_shortcut_bias: bool = True,
        conv_2d_out_channels: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

218 """
219
220 def __init__(
221 self,
222 *,
223 in_channels: int,
224 out_channels: Optional[int] = None,
225 conv_shortcut: bool = False,
226 dropout: float = 0.0,
227 temb_channels: int = 512,
228 groups: int = 32,
229 groups_out: Optional[int] = None,
230 pre_norm: bool = True,
231 eps: float = 1e-6,
232 non_linearity: str = "swish",
233 skip_time_act: bool = False,
234 time_embedding_norm: str = "default", # default, scale_shift,
235 kernel: Optional[torch.Tensor] = None,
236 output_scale_factor: float = 1.0,
237 use_in_shortcut: Optional[bool] = None,
238 up: bool = False,
239 down: bool = False,
240 conv_shortcut_bias: bool = True,
241 conv_2d_out_channels: Optional[int] = None,
242 ):
243 super().__init__()
244 if time_embedding_norm == "ada_group":
245 raise ValueError(
246 "This class cannot be used with `time_embedding_norm==ada_group`, please use `ResnetBlockCondNorm2D` instead",
247 )
248 if time_embedding_norm == "spatial":
249 raise ValueError(
250 "This class cannot be used with `time_embedding_norm==spatial`, please use `ResnetBlockCondNorm2D` instead",
251 )
252
253 self.pre_norm = True
254 self.in_channels = in_channels
255 out_channels = in_channels if out_channels is None else out_channels
256 self.out_channels = out_channels
257 self.use_conv_shortcut = conv_shortcut
258 self.up = up
259 self.down = down
260 self.output_scale_factor = output_scale_factor
261 self.time_embedding_norm = time_embedding_norm
262 self.skip_time_act = skip_time_act
263
264 if groups_out is None:
265 groups_out = groups
266
267 self.norm1 = torch.nn.GroupNorm(num_groups=groups, num_channels=in_channels, eps=eps, affine=True)
268
269 self.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1)
270
271 if temb_channels is not None:
272 if self.time_embedding_norm == "default":
273 self.time_emb_proj = nn.Linear(temb_channels, out_channels)
274 elif self.time_embedding_norm == "scale_shift":
275 self.time_emb_proj = nn.Linear(temb_channels, 2 * out_channels)
276 else:
277 raise ValueError(f"unknown time_embedding_norm : {self.time_embedding_norm} ")

Callers

nothing calls this directly

Calls 6

get_activationFunction · 0.85
upsample_2dFunction · 0.85
Upsample2DClass · 0.85
downsample_2dFunction · 0.85
Downsample2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected