MCPcopy Create free account
hub / github.com/huggingface/diffusers / __init__

Method __init__

src/diffusers/models/unets/unet_2d_blocks.py:1998–2041  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        out_channels: int,
        temb_channels: int,
        dropout: float = 0.0,
        num_layers: int = 4,
        resnet_eps: float = 1e-5,
        resnet_act_fn: str = "gelu",
        resnet_group_size: int = 32,
        add_downsample: bool = False,
    )

Source from the content-addressed store, hash-verified

1996
1997class KDownBlock2D(nn.Module):
1998 def __init__(
1999 self,
2000 in_channels: int,
2001 out_channels: int,
2002 temb_channels: int,
2003 dropout: float = 0.0,
2004 num_layers: int = 4,
2005 resnet_eps: float = 1e-5,
2006 resnet_act_fn: str = "gelu",
2007 resnet_group_size: int = 32,
2008 add_downsample: bool = False,
2009 ):
2010 super().__init__()
2011 resnets = []
2012
2013 for i in range(num_layers):
2014 in_channels = in_channels if i == 0 else out_channels
2015 groups = in_channels // resnet_group_size
2016 groups_out = out_channels // resnet_group_size
2017
2018 resnets.append(
2019 ResnetBlockCondNorm2D(
2020 in_channels=in_channels,
2021 out_channels=out_channels,
2022 dropout=dropout,
2023 temb_channels=temb_channels,
2024 groups=groups,
2025 groups_out=groups_out,
2026 eps=resnet_eps,
2027 non_linearity=resnet_act_fn,
2028 time_embedding_norm="ada_group",
2029 conv_shortcut_bias=False,
2030 )
2031 )
2032
2033 self.resnets = nn.ModuleList(resnets)
2034
2035 if add_downsample:
2036 # YiYi's comments- might be able to use FirDownsample2D, look into details later
2037 self.downsamplers = nn.ModuleList([KDownsample2D()])
2038 else:
2039 self.downsamplers = None
2040
2041 self.gradient_checkpointing = False
2042
2043 def forward(
2044 self, hidden_states: torch.Tensor, temb: torch.Tensor | None = None, *args, **kwargs

Callers

nothing calls this directly

Calls 3

KDownsample2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected