Mel-Band RoFormer Duality and KARA 2 student
A model that separates a song into the instrumental, the lead vocals and the
backing vocals in one pass, made for Musetric.
It is distilled anew from Aname's
Mel-Band RoFormer Duality
for the vocals, with a second mask that splits its vocals into lead and
backing, distilled from UVR MDX-Net KARA 2 of
Ultimate Vocal Remover.
It is narrower than the previous revision of this repository,
50840af,
and scores as well on true stems: 116.0 M parameters against 135.0 M, and
its core peaks at 1232 MiB of GPU memory against 1492 MiB in a browser, at
the same speed.
These are the PyTorch weights in fp32 and their config: the original model,
from which the app's ONNX core is exported. The class that reads them is
LeadBackingRoformer
of musetric/lab.
Intended uses & limitations
Intended:
- Instrumental / lead vocals / backing vocals separation of songs, 44.1 kHz stereo, on 11 s windows.
- A source for exports to ONNX.
Limitations:
- The vocals: 11.24 dB median SDR on MUSDB18-HQ, 0.85 dB below Duality's 12.09 dB.
- The split learns KARA 2's: what counts as backing is what KARA 2 takes out of the vocals; on true stems it separates the backing weakly (median SDR 0.5 to 1.9 dB, below).
- Trained and checked on 11 s windows (1101 STFT frames, hop 441).
How to use
import yaml
from safetensors.torch import load_file
from musetric_toolkit.separate_audio.roformer.lead_backing_roformer import LeadBackingRoformer
config = yaml.safe_load(open("config.yaml"))
model = LeadBackingRoformer(**config["model"]).eval()
model.load_state_dict(load_file("model.safetensors"))
stems = model.separate(audio) # audio: float32 [batch, 2, samples] at 44.1 kHz, an 11 s window
# stems["vocals"], stems["backing"], stems["lead"] = vocals - backing, stems["instrumental"] = audio - vocals
model.net_forward(stft_repr) is the neural network core alone: a real STFT
[batch, 2050, frames, 2] in, two masks per band out, the vocals mask over the
mix and the backing mask over the vocals; stem_spectra averages them per bin
and applies them.
Files
| File | Size | SHA256 |
|---|---|---|
model.safetensors | 464,168,152 B | 1f2dfa76eb7968bbaa004850b0f4654691da21cf60b4e5df3f9a2784ab765845 |
config.yaml | 1,170 B | 9ffaeac11097e3a4271bd04b557684d54fe77c87838908d0797bbdce8b512c1f |
training-data.csv | 2,072,765 B | baab7435e3c168ee87426ac443ff9c7ce8443e443aa0406e7a2c987f6dac11e4 |
The shape
116.0 M parameters: 90.5 M for the vocals and a split mask estimator of 25.5 M. Against Duality:
- A narrower stream. 288 features between the layers instead of 384: Duality's weights in the basis of the stream's 288 principal directions on training crops, the scales of the norms folded into the matrices that read the stream. One direction alone holds 36 to 78 % of the stream's energy after each transformer, the 288 hold 98 to 99.8 %.
- Pooled pairs. Pairs 0-1 run at full rate, pairs 2-5 on frames averaged by 2. A pooled pair adds its change back at full rate, x + up(F(down x) - down x), and its time positions are stretched by the same factor.
- Merged high bands. In every pair the bands from 44 up run merged in neighbouring pairs, 52 band tokens instead of 60, each merged band at the mean position of the two.
- Pairs 0-1. Time attention sees 32 frames on each side with 4 of the 8 heads, the feed-forward is 768 wide instead of 1536, and the band transformer is a residual linear map.
- Detail paths. Pairs 2-3 add a linear map of the detail their pooled view misses: the stream minus that view, and the view.
- Mask estimator. Per band a 288 x 1536 first layer, the 1536 x 1536 middle layer at rank 128 and Duality's last layer; it runs on pairs of frames, its masks repeated.
- Split estimator. Per band a 288 x 768 linear layer, a tanh and a linear layer to twice the band's size, gated like the vocals estimator, on the same pooled output of the stack. The backing is the vocals' spectrum times the split mask, and the lead is the vocals minus the backing, so the lead and the backing sum to the vocals.
Training
- Start. Duality's weights in the narrower stream, trained 40 minutes against Duality; each other narrowed part from a fit to that narrowed model on the training data (the kept feed-forward units, the pruned heads, the low-rank middle of the mask estimator and the detail paths), the band maps later from a fit on the trained stack.
- Vocals, about 9 h 50 min on one 16 GB GPU, batch 1: Duality online on every crop, multi-resolution STFT L1 of the vocals plus the distance to Duality's masks. 240 minutes, then 220 with the band maps of pairs 0-1, then 90 in which pairs 4-5 learned beside a first split estimator, their vocals held to Duality's; that estimator is not in this model.
- Lead and backing, 5 h 20 min in three runs, batch 2, as the previous revision learned them. The labels are this model's own vocals and KARA 2's backing of them, at the volume compensation of KARA 2's model data (1.065), as the app applies it. 60 min on the songs, 240 min with a cappellas in a fifth of the examples, and 20 min at lower learning rates. The split estimator learns at 1e-3, the last two pairs of the stack at 3e-5. The loss is multi-resolution STFT L1 on the backing and on the lead, plus three times the same on the vocals against the labels, which keeps the vocals output where it was.
- Data. 6,094 30 s clips of the FMA dataset
(50.1 h) and 470 a cappellas from ccMixter (20.7 h),
under CC BY 1.0, 2.0, 2.5, 3.0 and 4.0, CC0 1.0 and Public Domain Mark 1.0;
the a cappellas are also remixed over the accompaniment of other clips. No
NonCommercial, NoDerivatives or ShareAlike material. Every track the model
learned from, with its artist, license and source, is in
training-data.csv. - Not trained on: MUSDB18-HQ, and the uploaders of the test set below.
Evaluation
Against the previous revision, 50840af. SDR over whole tracks; paired differences are the mean of this model
minus the previous one per track, with a 95 % bootstrap interval.
Lead and backing against true stems. The test set is 41 ccMixter a
cappellas whose lead and backing are separate uploads, by 11 uploaders under
CC BY and CC0, 18 of them also over the upload's own instrument stems
(data-ccmixter-voices of musetric/lab). The backing is scored where it is no
more than 20 dB below the vocals.
| Set | Stem | This model, median | Previous, median | Paired difference |
|---|---|---|---|---|
| Mixes (18) | Lead | 6.20 dB | 5.68 dB | +0.18 dB [-0.02, +0.45] |
| Mixes (18) | Backing | 1.90 dB | 1.35 dB | +0.25 dB [-0.00, +0.57] |
| Mixes (18) | Vocals | 12.76 dB | 13.21 dB | +0.13 dB [-0.06, +0.28] |
| A cappellas (41) | Lead | 3.65 dB | 3.67 dB | +0.04 dB [-0.04, +0.15] |
| A cappellas (41) | Backing | 0.49 dB | 0.51 dB | +0.02 dB [-0.09, +0.14] |
On the tracks where the backing of the student followed by KARA 2 scores above 2 dB, where KARA 2 really splits, this model's backing is 0.37 dB [+0.03, +0.90] above the previous model's on the 8 mixes and 0.06 dB [-0.40, +0.26] below on the 10 a cappellas.
Vocals on MUSDB18-HQ, test, 50 tracks, 11 s windows every 8 s: median SDR 11.24 dB against 11.23 dB; paired, -0.03 dB [-0.15, +0.08].
Memory and speed. The ONNX core in Chrome on WebGPU on a desktop GPU (RTX 5070 Ti), one 11 s window: the peak of its GPU buffers 1232 MiB against 1492 MiB, 149 ms for both (median of ten runs). The core's weights file is 235 MB against 273 MB. On onnxruntime CUDA the core takes 68.5 ms against 59.3 ms; a whole song in PyTorch fp16, Rxbyn – Bad Side (3:37, CC BY), 2.49 s against 2.45 s.
The work is described in musetric/musetric#1088.
Source & lineage
- Vocals teacher and starting weights:
Aname-Tommy/Mel-Band-Roformer_Duality@07a189ffdceb69db0ddacc5175569bef59850016,duality_v1.ckpt, Apache-2.0. It is a fine-tune ofSYH99999/MelBandRoformerMergedSYHFTBeta1(MIT), which builds onKimberleyJSN/melbandroformer(MIT). - Split teacher: UVR MDX-Net KARA 2,
UVR_MDXNET_KARA_2.onnxof the Ultimate Vocal Remover model release, trained by the developers of Ultimate Vocal Remover, MIT; the app's export of it ismusetric/uvr-mdxnet-kara2-onnx. - Architecture: Mel-Band RoFormer (arXiv:2310.01809).
- Reference implementation:
lucidrains/BS-RoFormer, MIT. - Code:
release-voicesand the lead/backing recipe of musetric/lab at6daf2f3. - Changes by Musetric: the shape above, and its weights trained by distillation from the two teachers on the data above.
License & citation
Apache-2.0, as Duality's weights it starts from. The split is distilled from KARA 2, MIT, with credit to Ultimate Vocal Remover and its developers. We do not claim authorship of the teachers; the compression, the split and the training are ours.
@article{wang2023melbandroformer,
title={Mel-Band RoFormer for Music Source Separation},
author={Wang, Ju-Chiang and Lu, Wei-Tsung and Won, Minz},
journal={arXiv preprint arXiv:2310.01809},
year={2023}
}