Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick fix for XUMX in torch 2.0 #684

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions asteroid/models/x_umx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@


class XUMX(BaseModel):
def __init__(self, *args, **kwargs):
raise RuntimeError(
"XUMX is broken in torch 2.0, use torch<2.0 with asteroid<0.7 to use it until it's fixed."
)


class BrokenXUMX(BaseModel):
r"""CrossNet-Open-Unmix (X-UMX) for Music Source Separation introduced in [1].
There are two notable contributions with no effect on inference:
a) Multi Domain Losses
Expand Down Expand Up @@ -352,8 +345,9 @@ def forward(self, x):
normalized=False,
onesided=True,
pad_mode="reflect",
return_complex=False,
return_complex=True,
)
stft_f = torch.view_as_real(stft_f)

# reshape back to channel dimension
stft_f = stft_f.contiguous().view(nb_samples, nb_channels, self.n_fft // 2 + 1, -1, 2)
Expand Down Expand Up @@ -405,6 +399,7 @@ def forward(self, spec, ang):
x_i = spec * torch.sin(ang)
x = torch.stack([x_r, x_i], dim=-1)
x = x.view(sources * bsize * channels, fbins, frames, 2)
x = torch.view_as_complex(x)
wav = torch.istft(
x, n_fft=self.n_fft, hop_length=self.hop_length, window=self.window, center=self.center
)
Expand Down