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

Function tensor_to_vae_latent

train_single.py:372–384  ·  view source on GitHub ↗
(t, vae, scale=True)

Source from the content-addressed store, hash-verified

370
371
372def tensor_to_vae_latent(t, vae, scale=True):
373 t = t.to(vae.dtype)
374 if len(t.shape) == 5:
375 video_length = t.shape[1]
376
377 t = rearrange(t, "b f c h w -> (b f) c h w")
378 latents = vae.encode(t).latent_dist.sample()
379 latents = rearrange(latents, "(b f) c h w -> b f c h w", f=video_length)
380 elif len(t.shape) == 4:
381 latents = vae.encode(t).latent_dist.sample()
382 if scale:
383 latents = latents * vae.config.scaling_factor
384 return latents
385
386
387def parse_args():

Callers 1

mainFunction · 0.70

Calls 2

sampleMethod · 0.80
encodeMethod · 0.80

Tested by

no test coverage detected