MCPcopy Create free account
hub / github.com/Francis-Rings/StableAnimator / forward

Method forward

animation/modules/unet_3d_blocks.py:859–899  ·  view source on GitHub ↗
(
        self,
        hidden_states: torch.Tensor,
        res_hidden_states_tuple: Tuple[torch.Tensor, ...],
        temb: Optional[torch.Tensor] = None,
        upsample_size: Optional[int] = None,
        num_frames: int = 1,
    )

Source from the content-addressed store, hash-verified

857 self.resolution_idx = resolution_idx
858
859 def forward(
860 self,
861 hidden_states: torch.Tensor,
862 res_hidden_states_tuple: Tuple[torch.Tensor, ...],
863 temb: Optional[torch.Tensor] = None,
864 upsample_size: Optional[int] = None,
865 num_frames: int = 1,
866 ) -> torch.Tensor:
867 is_freeu_enabled = (
868 getattr(self, "s1", None)
869 and getattr(self, "s2", None)
870 and getattr(self, "b1", None)
871 and getattr(self, "b2", None)
872 )
873 for resnet, temp_conv in zip(self.resnets, self.temp_convs):
874 # pop res hidden states
875 res_hidden_states = res_hidden_states_tuple[-1]
876 res_hidden_states_tuple = res_hidden_states_tuple[:-1]
877
878 # FreeU: Only operate on the first two stages
879 if is_freeu_enabled:
880 hidden_states, res_hidden_states = apply_freeu(
881 self.resolution_idx,
882 hidden_states,
883 res_hidden_states,
884 s1=self.s1,
885 s2=self.s2,
886 b1=self.b1,
887 b2=self.b2,
888 )
889
890 hidden_states = torch.cat([hidden_states, res_hidden_states], dim=1)
891
892 hidden_states = resnet(hidden_states, temb)
893 hidden_states = temp_conv(hidden_states, num_frames=num_frames)
894
895 if self.upsamplers is not None:
896 for upsampler in self.upsamplers:
897 hidden_states = upsampler(hidden_states, upsample_size)
898
899 return hidden_states
900
901
902class MidBlockTemporalDecoder(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected