MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / Res3DBlockUpsample

Class Res3DBlockUpsample

diffsynth/models/stepvideo_vae.py:676–727  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674
675
676class Res3DBlockUpsample(nn.Module):
677 def __init__(self,
678 input_filters,
679 num_filters,
680 down_sampling_stride,
681 down_sampling=False
682 ):
683 super().__init__()
684
685 self.input_filters = input_filters
686 self.num_filters = num_filters
687
688 self.act_ = nn.SiLU(inplace=True)
689
690 self.conv1 = CausalConvChannelLast(num_filters, num_filters, kernel_size=[3, 3, 3])
691 self.norm1 = BaseGroupNorm(32, num_filters)
692
693 self.conv2 = CausalConvChannelLast(num_filters, num_filters, kernel_size=[3, 3, 3])
694 self.norm2 = BaseGroupNorm(32, num_filters)
695
696 self.down_sampling = down_sampling
697 if down_sampling:
698 self.down_sampling_stride = down_sampling_stride
699 else:
700 self.down_sampling_stride = [1, 1, 1]
701
702 if num_filters != input_filters or down_sampling:
703 self.conv3 = CausalConvChannelLast(input_filters, num_filters, kernel_size=[1, 1, 1], stride=self.down_sampling_stride)
704 self.norm3 = BaseGroupNorm(32, num_filters)
705
706 def forward(self, x, is_init=False):
707 x = x.permute(0,2,3,4,1).contiguous()
708
709 residual = x
710
711 h = self.conv1(x, is_init)
712 h = self.norm1(h, act_silu=True, channel_last=True)
713
714 h = self.conv2(h, is_init)
715 h = self.norm2(h, act_silu=False, channel_last=True)
716
717 if self.down_sampling or self.num_filters != self.input_filters:
718 x = self.conv3(x, is_init)
719 x = self.norm3(x, act_silu=False, channel_last=True)
720
721 h.add_(x)
722 h = self.act_(h)
723 if residual is not None:
724 h.add_(residual)
725
726 h = h.permute(0,4,1,2,3)
727 return h
728
729class Upsample3D(nn.Module):
730 def __init__(self,

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected