MCPcopy Create free account
hub / github.com/MeiGen-AI/InfiniteTalk / unpatchify

Method unpatchify

wan/modules/multitalk_model.py:777–800  ·  view source on GitHub ↗

r""" Reconstruct video tensors from patch embeddings. Args: x (List[Tensor]): List of patchified features, each with shape [L, C_out * prod(patch_size)] grid_sizes (Tensor): Original spatial-temporal grid dimensions before patc

(self, x, grid_sizes)

Source from the content-addressed store, hash-verified

775
776
777 def unpatchify(self, x, grid_sizes):
778 r"""
779 Reconstruct video tensors from patch embeddings.
780
781 Args:
782 x (List[Tensor]):
783 List of patchified features, each with shape [L, C_out * prod(patch_size)]
784 grid_sizes (Tensor):
785 Original spatial-temporal grid dimensions before patching,
786 shape [B, 3] (3 dimensions correspond to F_patches, H_patches, W_patches)
787
788 Returns:
789 List[Tensor]:
790 Reconstructed video tensors with shape [C_out, F, H / 8, W / 8]
791 """
792
793 c = self.out_dim
794 out = []
795 for u, v in zip(x, grid_sizes.tolist()):
796 u = u[:math.prod(v)].view(*v, *self.patch_size, c)
797 u = torch.einsum('fhwpqrc->cfphqwr', u)
798 u = u.reshape(c, *[i * j for i, j in zip(v, self.patch_size)])
799 out.append(u)
800 return out
801
802 def init_weights(self):
803 r"""

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected