Skip to content

Commit 0e0e3c5

Browse files
committed
fix: demucs not working
1 parent 73a26d3 commit 0e0e3c5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

backend/serve.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def setup(self, device: str):
3232
)
3333
self.model.eval()
3434
self.demucs_model = pretrained.get_model("htdemucs")
35-
self.demucs_model.modules = self.demucs_model.modules.to(device)
3635
self.transform = A.Compose(
3736
[
3837
A.AddGaussianNoise(p=0.2),
@@ -57,11 +56,8 @@ def separate_audio(self, audio_path: str) -> str:
5756
wav = wav.mean(dim=0, keepdim=True)
5857

5958
with torch.no_grad():
60-
sources = apply_model(
61-
self.demucs_model,
62-
wav,
63-
shifts=1,
64-
)
59+
sources = apply_model(self.demucs_model, wav.unsqueeze(0), shifts=1)
60+
6561
vocals = sources[0, 3]
6662
separated_path = f"/tmp/separated_{time.time()}.wav"
6763
torchaudio.save(separated_path, vocals, sr)

0 commit comments

Comments
 (0)