Spaces:
Build error
Build error
Download codeclm/tokenizer/Flow1dVAE/tools/get_1dvae.py from NeoPy/SongGeneration: direct link, hf CLI and curl.
- Browser
- Download file 472 Bytes
-
https://huggingface.co/spaces/NeoPy/SongGeneration/resolve/main/codeclm/tokenizer/Flow1dVAE/tools/get_1dvae.py
- Command line
-
hf download hf://spaces/NeoPy/SongGeneration/codeclm/tokenizer/Flow1dVAE/tools/get_1dvae.py
-
curl -L -o get_1dvae.py https://huggingface.co/spaces/NeoPy/SongGeneration/resolve/main/codeclm/tokenizer/Flow1dVAE/tools/get_1dvae.py
472 Bytes
| import torch | |
| from tqdm import tqdm | |
| import torchaudio | |
| from third_party.stable_audio_tools.stable_audio_tools.models.autoencoders import create_autoencoder_from_config | |
| import numpy as np | |
| import os | |
| import json | |
| def get_model(model_config, path): | |
| with open(model_config) as f: | |
| model_config = json.load(f) | |
| state_dict = torch.load(path) | |
| model = create_autoencoder_from_config(model_config) | |
| model.load_state_dict(state_dict['state_dict']) | |
| return model |