re-support onnx export for cpu

This commit is contained in:
wataru 2023-04-14 15:48:38 +09:00
parent 4171baa6de
commit 1c8d891a7d
2 changed files with 6 additions and 2 deletions

View File

@ -340,5 +340,10 @@ class RVC:
output_path = os.path.join(TMP_DIR, output_file)
output_path_simple = os.path.join(TMP_DIR, output_file_simple)
onnxExporter.export2onnx(self.settings.pyTorchModelFile, output_path, output_path_simple, True)
if torch.cuda.device_count() > 0:
onnxExporter.export2onnx(self.settings.pyTorchModelFile, output_path, output_path_simple, True)
else:
print("[Voice Changer] Warning!!! onnx export with float32. maybe size is doubled.")
onnxExporter.export2onnx(self.settings.pyTorchModelFile, output_path, output_path_simple, False)
return {"status": "ok", "path": f"/tmp/{output_file_simple}", "filename": output_file_simple}

View File

@ -99,7 +99,6 @@ class SynthesizerTrnMs256NSFsid_ONNX(nn.Module):
def export2onnx(input_model, output_model, output_model_simple, is_half):
is_half = False
cpt = torch.load(input_model, map_location="cpu")
if is_half:
dev = torch.device("cuda", index=0)