Download scripts/cloning_check.py from matthiastl/gepard-onnx: direct link, hf CLI and curl.
- Browser
- Download file 777 Bytes
-
https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/cloning_check.py
- Command line
-
hf download hf://matthiastl/gepard-onnx/scripts/cloning_check.py
-
curl -L -o cloning_check.py https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/cloning_check.py
777 Bytes
| """RULE-2 5: voice encoder and compressor in ONNX against the original, on 3 clips.""" | |
| import sys; from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| import numpy as np, onnxruntime as ort | |
| ROOT = Path(__file__).resolve().parents[1] | |
| e, c = [ort.InferenceSession(str(ROOT / f"export/{n}.onnx"), providers=["CPUExecutionProvider"]) for n in ("codec_encoder", "compressor")] | |
| for k in range(3): | |
| d = np.load(ROOT / f"runs/clips/{k}.npz"); codes = e.run(None, {"audio": d["wav"][None]})[0][0]; pre = c.run(None, {"codes": codes[None]})[0][0]; a = d["prefix"] | |
| cos = (pre * a).sum(-1) / (np.linalg.norm(pre, axis=-1) * np.linalg.norm(a, axis=-1)); print(f"clip {k}: codes agree {100 * (codes == d['codes']).mean():.2f}%, prefix cosine min {cos.min():.6f}") | |