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

Method setup

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

Source from the content-addressed store, hash-verified

504 dtype: jnp.dtype = jnp.float32
505
506 def setup(self):
507 block_out_channels = self.block_out_channels
508 # in
509 self.conv_in = nn.Conv(
510 block_out_channels[0],
511 kernel_size=(3, 3),
512 strides=(1, 1),
513 padding=((1, 1), (1, 1)),
514 dtype=self.dtype,
515 )
516
517 # downsampling
518 down_blocks = []
519 output_channel = block_out_channels[0]
520 for i, _ in enumerate(self.down_block_types):
521 input_channel = output_channel
522 output_channel = block_out_channels[i]
523 is_final_block = i == len(block_out_channels) - 1
524
525 down_block = FlaxDownEncoderBlock2D(
526 in_channels=input_channel,
527 out_channels=output_channel,
528 num_layers=self.layers_per_block,
529 resnet_groups=self.norm_num_groups,
530 add_downsample=not is_final_block,
531 dtype=self.dtype,
532 )
533 down_blocks.append(down_block)
534 self.down_blocks = down_blocks
535
536 # middle
537 self.mid_block = FlaxUNetMidBlock2D(
538 in_channels=block_out_channels[-1],
539 resnet_groups=self.norm_num_groups,
540 num_attention_heads=None,
541 dtype=self.dtype,
542 )
543
544 # end
545 conv_out_channels = 2 * self.out_channels if self.double_z else self.out_channels
546 self.conv_norm_out = nn.GroupNorm(num_groups=self.norm_num_groups, epsilon=1e-6)
547 self.conv_out = nn.Conv(
548 conv_out_channels,
549 kernel_size=(3, 3),
550 strides=(1, 1),
551 padding=((1, 1), (1, 1)),
552 dtype=self.dtype,
553 )
554
555 def __call__(self, sample, deterministic: bool = True):
556 # in

Callers

nothing calls this directly

Calls 2

FlaxUNetMidBlock2DClass · 0.85

Tested by

no test coverage detected