MCPcopy Create free account
hub / github.com/CompVis/zigma / unpatchify

Method unpatchify

model_zigma.py:874–887  ·  view source on GitHub ↗

x: (N, T, patch_size**2 * C) imgs: (N, H, W, C)

(self, x)

Source from the content-addressed store, hash-verified

872 pass
873
874 def unpatchify(self, x):
875 """
876 x: (N, T, patch_size**2 * C)
877 imgs: (N, H, W, C)
878 """
879 c = self.out_channels
880 p = self.x_embedder.patch_size[0]
881 h = w = int(x.shape[1] ** 0.5)
882 assert h * w == x.shape[1]
883
884 x = x.reshape(shape=(x.shape[0], h, w, p, p, c))
885 x = torch.einsum("nhwpqc->nchpwq", x)
886 imgs = x.reshape(shape=(x.shape[0], c, h * p, h * p))
887 return imgs
888
889 def unpatchify_video(self, x, video_frames):
890 """

Callers 1

forwardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected