Spaces:
Running on Zero
Running on Zero
Download acestep/training/dataset_builder_modules/preprocess_vae.py from Gamahea/ACE-Step-Custom: direct link, hf CLI and curl.
- Browser
- Download file 358 Bytes
-
https://huggingface.co/spaces/Gamahea/ACE-Step-Custom/resolve/main/acestep/training/dataset_builder_modules/preprocess_vae.py
- Command line
-
hf download hf://spaces/Gamahea/ACE-Step-Custom/acestep/training/dataset_builder_modules/preprocess_vae.py
-
curl -L -o preprocess_vae.py https://huggingface.co/spaces/Gamahea/ACE-Step-Custom/resolve/main/acestep/training/dataset_builder_modules/preprocess_vae.py
358 Bytes
| import torch | |
| def vae_encode(vae, audio, dtype): | |
| """VAE encode audio to get target latents.""" | |
| model_device = next(vae.parameters()).device | |
| if audio.device != model_device: | |
| audio = audio.to(model_device) | |
| latent = vae.encode(audio).latent_dist.sample() | |
| target_latents = latent.transpose(1, 2).to(dtype) | |
| return target_latents | |