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

Method __init__

src/diffusers/models/autoencoders/vae.py:921–959  ·  view source on GitHub ↗
(
        self,
        in_channels: int,
        out_channels: int,
        num_blocks: Tuple[int, ...],
        block_out_channels: Tuple[int, ...],
        upsampling_scaling_factor: int,
        act_fn: str,
    )

Source from the content-addressed store, hash-verified

919 """
920
921 def __init__(
922 self,
923 in_channels: int,
924 out_channels: int,
925 num_blocks: Tuple[int, ...],
926 block_out_channels: Tuple[int, ...],
927 upsampling_scaling_factor: int,
928 act_fn: str,
929 ):
930 super().__init__()
931
932 layers = [
933 nn.Conv2d(in_channels, block_out_channels[0], kernel_size=3, padding=1),
934 get_activation(act_fn),
935 ]
936
937 for i, num_block in enumerate(num_blocks):
938 is_final_block = i == (len(num_blocks) - 1)
939 num_channels = block_out_channels[i]
940
941 for _ in range(num_block):
942 layers.append(AutoencoderTinyBlock(num_channels, num_channels, act_fn))
943
944 if not is_final_block:
945 layers.append(nn.Upsample(scale_factor=upsampling_scaling_factor))
946
947 conv_out_channel = num_channels if not is_final_block else out_channels
948 layers.append(
949 nn.Conv2d(
950 num_channels,
951 conv_out_channel,
952 kernel_size=3,
953 padding=1,
954 bias=is_final_block,
955 )
956 )
957
958 self.layers = nn.Sequential(*layers)
959 self.gradient_checkpointing = False
960
961 def forward(self, x: torch.FloatTensor) -> torch.FloatTensor:
962 r"""The forward method of the `DecoderTiny` class."""

Callers

nothing calls this directly

Calls 3

get_activationFunction · 0.85
__init__Method · 0.45

Tested by

no test coverage detected