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

Function tensor_to_vae_latent

train.py:368–380  ·  view source on GitHub ↗
(t, vae, scale=True)

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.70

Calls 2

sampleMethod · 0.80
encodeMethod · 0.80

Tested by

no test coverage detected