MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / __init__

Method __init__

src/diffusers/models/unets/unet_2d_blocks.py:1784–1841  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        out_channels: int,
        temb_channels: int,
        dropout: float = 0.0,
        num_layers: int = 1,
        resnet_eps: float = 1e-6,
        resnet_time_scale_shift: str = "default",
        resnet_act_fn: str = "swish",
        resnet_pre_norm: bool = True,
        output_scale_factor: float = np.sqrt(2.0),
        add_downsample: bool = True,
        downsample_padding: int = 1,
    )

Source from the content-addressed store, hash-verified

1782
1783class SkipDownBlock2D(nn.Module):
1784 def __init__(
1785 self,
1786 in_channels: int,
1787 out_channels: int,
1788 temb_channels: int,
1789 dropout: float = 0.0,
1790 num_layers: int = 1,
1791 resnet_eps: float = 1e-6,
1792 resnet_time_scale_shift: str = "default",
1793 resnet_act_fn: str = "swish",
1794 resnet_pre_norm: bool = True,
1795 output_scale_factor: float = np.sqrt(2.0),
1796 add_downsample: bool = True,
1797 downsample_padding: int = 1,
1798 ):
1799 super().__init__()
1800 self.resnets = nn.ModuleList([])
1801
1802 for i in range(num_layers):
1803 in_channels = in_channels if i == 0 else out_channels
1804 self.resnets.append(
1805 ResnetBlock2D(
1806 in_channels=in_channels,
1807 out_channels=out_channels,
1808 temb_channels=temb_channels,
1809 eps=resnet_eps,
1810 groups=min(in_channels // 4, 32),
1811 groups_out=min(out_channels // 4, 32),
1812 dropout=dropout,
1813 time_embedding_norm=resnet_time_scale_shift,
1814 non_linearity=resnet_act_fn,
1815 output_scale_factor=output_scale_factor,
1816 pre_norm=resnet_pre_norm,
1817 )
1818 )
1819
1820 if add_downsample:
1821 self.resnet_down = ResnetBlock2D(
1822 in_channels=out_channels,
1823 out_channels=out_channels,
1824 temb_channels=temb_channels,
1825 eps=resnet_eps,
1826 groups=min(out_channels // 4, 32),
1827 dropout=dropout,
1828 time_embedding_norm=resnet_time_scale_shift,
1829 non_linearity=resnet_act_fn,
1830 output_scale_factor=output_scale_factor,
1831 pre_norm=resnet_pre_norm,
1832 use_in_shortcut=True,
1833 down=True,
1834 kernel="fir",
1835 )
1836 self.downsamplers = nn.ModuleList([FirDownsample2D(out_channels, out_channels=out_channels)])
1837 self.skip_conv = nn.Conv2d(3, out_channels, kernel_size=(1, 1), stride=(1, 1))
1838 else:
1839 self.resnet_down = None
1840 self.downsamplers = None
1841 self.skip_conv = None

Callers

nothing calls this directly

Calls 3

ResnetBlock2DClass · 0.85
FirDownsample2DClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected