rvc-models / scripts /archive /stage5_retry.py
mistmlm's picture
rvc-model: build scripts, manifests and voice notes (mygf_wh now v73)
bda6de8 verified
Raw History Blame Contribute Delete
2.56 kB
"""Re-run encflow + decnsf compile only (flowreverse already saved).
Skip export (ONNX files exist). Compile with --truncate_64bit_io.
"""
import os
import shutil
import qai_hub
import onnx
OUT_BIN_DIR = "models/synthesizer"
os.makedirs(OUT_BIN_DIR, exist_ok=True)
T_PH = 15
PARTS = [
{
"name": "encflow",
"onnx": "models/synthesizer/encflow_T15.onnx",
"bin": "models/synthesizer/encflow_s23.bin",
"input_specs": {
"phone": ((1, T_PH, 768), "float32"),
"pitch": ((1, T_PH), "int64"),
"sid": ((1,), "int64"),
},
},
{
"name": "decnsf",
"onnx": "models/synthesizer/decnsf_T15.onnx",
"bin": "models/synthesizer/decnsf_s23.bin",
"input_specs": {
"z": ((1, 192, T_PH), "float32"),
"f0": ((1, T_PH), "float32"),
"sid": ((1,), "int64"),
},
},
]
def compile_part(part, s23):
if os.path.exists(part["bin"]) and os.path.getsize(part["bin"]) > 1_000_000:
print(f" {part['bin']} already exists ({os.path.getsize(part['bin'])/1e6:.1f} MB), skipping")
return None
onnx_model = onnx.load(part["onnx"])
print(f"\n--- compile {part['name']} ---")
job = qai_hub.submit_compile_job(
model=onnx_model,
device=s23,
input_specs=part["input_specs"],
options="--target_runtime qnn_context_binary --truncate_64bit_io",
)
print(f" job: {job.job_id}")
job.wait()
status = job.get_status()
print(f" status: {status}")
if str(status.state) != "State.SUCCESS":
print(f" FAILED: {status.message}")
try:
print(f" log: {job.download_artifacts_for_type(OUT_BIN_DIR, qai_hub.JobArtifactType.HUB_LOG)}")
except Exception as e:
print(f" (no log: {e})")
return None
got = job.download_target_model(part["bin"])
if got and os.path.isfile(got) and os.path.abspath(got) != os.path.abspath(part["bin"]):
shutil.move(got, part["bin"])
print(f" saved {part['bin']} ({os.path.getsize(part['bin'])/1e6:.1f} MB)")
return job.job_id
if __name__ == "__main__":
devs = qai_hub.get_devices()
s23 = next(d for d in devs if d.name == "Samsung Galaxy S23 (Family)")
print(f"target: {s23.name}")
for p in PARTS:
compile_part(p, s23)
print("\n--- final list ---")
for fn in sorted(os.listdir(OUT_BIN_DIR)):
if fn.endswith(".bin"):
print(f" {fn}: {os.path.getsize(os.path.join(OUT_BIN_DIR, fn))/1e6:.1f} MB")