File size: 512 Bytes
14a1f59
7cddcee
14a1f59
 
 
 
7cddcee
 
 
 
 
 
 
 
14a1f59
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
```python
import json
import onnx
import torch
from safetensors.torch import save_file
from huggingface_hub import hf_hub_download
state_dict = {}
state_dict_info = {}
for i in onnx.load(hf_hub_download("KittenML/kitten-tts-nano-0.8-int8","kitten_tts_nano_v0_8.onnx")).graph.initializer:
    p = onnx.numpy_helper.to_array(i)
    state_dict_info[i.name] = list(p.shape)
    state_dict[i.name] = torch.tensor(p)
json.dump(state_dict_info,open("KittenTTS.json","w"))
save_file(state_dict, "model.safetensors")

```