Spaces:
Running
Running
Upload halve.py
Browse files- KOKORO/fp16/halve.py +17 -0
KOKORO/fp16/halve.py
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from hashlib import sha256
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
path = Path(__file__).parent.parent / 'kokoro-v0_19.pth'
|
| 6 |
+
assert path.exists(), f'No model pth found at {path}'
|
| 7 |
+
|
| 8 |
+
net = torch.load(path, map_location='cpu', weights_only=True)['net']
|
| 9 |
+
for a in net:
|
| 10 |
+
for b in net[a]:
|
| 11 |
+
net[a][b] = net[a][b].half()
|
| 12 |
+
|
| 13 |
+
torch.save(dict(net=net), 'kokoro-v0_19-half.pth')
|
| 14 |
+
with open('kokoro-v0_19-half.pth', 'rb') as rb:
|
| 15 |
+
h = sha256(rb.read()).hexdigest()
|
| 16 |
+
|
| 17 |
+
assert h == '70cbf37f84610967f2ca72dadb95456fdd8b6c72cdd6dc7372c50f525889ff0c', h
|