MCPcopy
hub / github.com/Wan-Video/Wan2.2 / patchify

Function patchify

wan/modules/vae2_2.py:280–296  ·  view source on GitHub ↗
(x, patch_size)

Source from the content-addressed store, hash-verified

278
279
280def patchify(x, patch_size):
281 if patch_size == 1:
282 return x
283 if x.dim() == 4:
284 x = rearrange(
285 x, "b c (h q) (w r) -> b (c r q) h w", q=patch_size, r=patch_size)
286 elif x.dim() == 5:
287 x = rearrange(
288 x,
289 "b c f (h q) (w r) -> b (c r q) f h w",
290 q=patch_size,
291 r=patch_size,
292 )
293 else:
294 raise ValueError(f"Invalid input shape: {x.shape}")
295
296 return x
297
298
299def unpatchify(x, patch_size):

Callers 1

encodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected