MCPcopy Create free account
hub / github.com/Francis-Rings/FlashPortrait / patchify

Function patchify

wan/models/wan_vae3_8.py:285–301  ·  view source on GitHub ↗
(x, patch_size)

Source from the content-addressed store, hash-verified

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

Callers 1

encodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected