Skip to content

Commit

Permalink
Attempt to fix windows MDX ONNX loading tempfile bug in onnx2torch (#63)
Browse files Browse the repository at this point in the history
* Attempt to fix windows MDX ONNX loading tempfile bug in onnx2torch

* Bumped version with onnx2torch windows fix
  • Loading branch information
beveradb authored Apr 26, 2024
1 parent bcbbc51 commit 0f9d361
Show file tree
Hide file tree
Showing 3 changed files with 439 additions and 389 deletions.
9 changes: 8 additions & 1 deletion audio_separator/separator/architectures/mdx_separator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Module for separating audio sources using MDX architecture models."""

import os
import platform
import torch
import onnx
import onnxruntime as ort
import numpy as np
import onnx2torch
Expand Down Expand Up @@ -121,7 +123,12 @@ def load_model(self):
self.model_run = lambda spek: ort_inference_session.run(None, {"input": spek.cpu().numpy()})[0]
self.logger.debug("Model loaded successfully using ONNXruntime inferencing session.")
else:
self.model_run = onnx2torch.convert(self.model_path)
if platform.system() == 'Windows':
onnx_model = onnx.load(self.model_path)
self.model_run = onnx2torch.convert(onnx_model)
else:
self.model_run = onnx2torch.convert(self.model_path)

self.model_run.to(self.torch_device).eval()
self.logger.warning("Model converted from onnx to pytorch due to segment size not matching dim_t, processing may be slower.")

Expand Down
Loading

0 comments on commit 0f9d361

Please sign in to comment.