Skip to content

Commit

Permalink
Attempt to fix windows MDX ONNX loading tempfile bug in onnx2torch
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Apr 25, 2024
1 parent bcbbc51 commit 3ad9e61
Showing 1 changed file with 8 additions and 1 deletion.
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)

Check warning on line 128 in audio_separator/separator/architectures/mdx_separator.py

View check run for this annotation

Codecov / codecov/patch

audio_separator/separator/architectures/mdx_separator.py#L126-L128

Added lines #L126 - L128 were not covered by tests
else:
self.model_run = onnx2torch.convert(self.model_path)

Check warning on line 130 in audio_separator/separator/architectures/mdx_separator.py

View check run for this annotation

Codecov / codecov/patch

audio_separator/separator/architectures/mdx_separator.py#L130

Added line #L130 was not covered by tests

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

0 comments on commit 3ad9e61

Please sign in to comment.