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

Method setup

src/diffusers/models/vae_flax.py:618–669  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

616 dtype: jnp.dtype = jnp.float32
617
618 def setup(self):
619 block_out_channels = self.block_out_channels
620
621 # z to block_in
622 self.conv_in = nn.Conv(
623 block_out_channels[-1],
624 kernel_size=(3, 3),
625 strides=(1, 1),
626 padding=((1, 1), (1, 1)),
627 dtype=self.dtype,
628 )
629
630 # middle
631 self.mid_block = FlaxUNetMidBlock2D(
632 in_channels=block_out_channels[-1],
633 resnet_groups=self.norm_num_groups,
634 num_attention_heads=None,
635 dtype=self.dtype,
636 )
637
638 # upsampling
639 reversed_block_out_channels = list(reversed(block_out_channels))
640 output_channel = reversed_block_out_channels[0]
641 up_blocks = []
642 for i, _ in enumerate(self.up_block_types):
643 prev_output_channel = output_channel
644 output_channel = reversed_block_out_channels[i]
645
646 is_final_block = i == len(block_out_channels) - 1
647
648 up_block = FlaxUpDecoderBlock2D(
649 in_channels=prev_output_channel,
650 out_channels=output_channel,
651 num_layers=self.layers_per_block + 1,
652 resnet_groups=self.norm_num_groups,
653 add_upsample=not is_final_block,
654 dtype=self.dtype,
655 )
656 up_blocks.append(up_block)
657 prev_output_channel = output_channel
658
659 self.up_blocks = up_blocks
660
661 # end
662 self.conv_norm_out = nn.GroupNorm(num_groups=self.norm_num_groups, epsilon=1e-6)
663 self.conv_out = nn.Conv(
664 self.out_channels,
665 kernel_size=(3, 3),
666 strides=(1, 1),
667 padding=((1, 1), (1, 1)),
668 dtype=self.dtype,
669 )
670
671 def __call__(self, sample, deterministic: bool = True):
672 # z to block_in

Callers

nothing calls this directly

Calls 2

FlaxUNetMidBlock2DClass · 0.85

Tested by

no test coverage detected