File size: 438 Bytes
258fd02
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import torch
from third_party.stable_audio_tools.stable_audio_tools.models.autoencoders import create_autoencoder_from_config
import json

def get_model(model_config, path):
    with open(model_config) as f:
        model_config = json.load(f)
    state_dict = torch.load(path, map_location='cpu')
    model = create_autoencoder_from_config(model_config)
    model.load_state_dict(state_dict['state_dict'], strict=False)
    return model