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