Views
No views yet
| tracks | Mini-BS-RoFormer-V2-46.8M | Mini-BS-RoFormer-18M | Mini-BS-RoFormer |
|---|---|---|---|
| overall | 10.03 | 9.01 | 6.48 |
| bass | 9.68 | 8.31 | 5.66 |
| drums | 10.58 | 9.55 | 6.77 |
| other | 8.99 | 8.14 | 6.06 |
| vocal | 10.86 | 10.03 | 7.44 |
| model | GFLOPs |
|---|---|
| Mini-BS-RoFormer-V2-46.8M | 8343.55 |
| Mini-BS-RoFormer-18M | 10115.77 |
| Mini-BS-RoFormer | 3068.64 |
1from transformers import AutoModel
2import soundfile
3import torch
4import librosa
5
6model_name = "HiDolen/Mini-BS-RoFormer-V2-46.8M"
7model = AutoModel.from_pretrained(
8 model_name,
9 trust_remote_code=True,
10)
11model.to("cuda")
12
13# 加载音频
14file = "./Bruno Mars - Runaway Baby.mp3"
15waveform, sr = librosa.load(file, sr=44100, mono=False)
16waveform = torch.tensor(waveform).float()
17waveform = waveform.to("cuda")
18
19# 进行推理
20result = model.separate(
21 waveform,
22 batch_size=2,
23 verbose=True,
24)
25
26# 保存处理结果
27for i in range(result.shape[0]):
28 soundfile.write(f"separated_stem_{i}.wav", result[i].cpu().numpy().T, 44100)1···
2
3result = model.separate(
4 waveform,
5 batch_size=2,
6 verbose=True,
7)
8
9# 合并 bass、drums、other 作为伴奏
10instrumental = result[0] + result[1] + result[2]
11vocals = result[3]
12result = torch.stack([instrumental, vocals], dim=0)
13for i in range(result.shape[0]):
14 soundfile.write(f"separated_stem_{i}.wav", result[i].cpu().numpy().T, 44100)