Roformer Instrumental (vocal removal) fine-tunes — ONNX
Two vocal/instrumental separation models fine-tuned for getting a clean instrumental (karaoke) from a full mix, exported to ONNX in FP32 and FP16:
| File | Base model | Precision | Size |
|---|---|---|---|
bs_roformer_inst_ft.onnx |
BS-Roformer, viperx edition (model_bs_roformer_ep_317_sdr_12.9755) |
FP32 | 645 MB |
bs_roformer_inst_ft_fp16.onnx |
same | FP16 | 324 MB |
mel_roformer_inst_ft.onnx |
Mel-Band-Roformer, KimberleyJensen edition (KimberleyJSN/melbandroformer) |
FP32 | 918 MB |
mel_roformer_inst_ft_fp16.onnx |
same | FP16 | 460 MB |
The FP16 files use FP16 weights and compute, with the RMSNorm normalisation kept in FP32 (it overflows in FP16). Their input and output are still float32, so the same inference code works for both. On a GPU, FP16 gives the same quality and is the recommended choice.
Both models predict the vocal stem; the instrumental is mixture − vocals. The training loss is on the vocal stem, which for these targets is the same as the error of the instrumental (see Training).
Results
Validation set: 16 songs held out from training (no other version of the same song was used in training). Instrumental metrics are computed on mixture − predicted vocals against the reference instrumental; mean over the 16 songs. Higher is better.
| Model | Inst. SDR | Inst. SI-SDR | Bleedless | Fullness |
|---|---|---|---|---|
| BS-Roformer (base) | 12.93 | 12.78 | 26.2 | 25.7 |
| BS-Roformer (this fine-tune) | 13.37 | 13.17 | 35.0 | 21.6 |
| Mel-Roformer (base) | 12.56 | 12.38 | 26.6 | 25.6 |
| Mel-Roformer (this fine-tune) | 13.22 | 12.99 | 33.8 | 22.2 |
- Instrumental SDR improves on 14 of 16 songs for each model.
- The largest change is less vocal bleed in the instrumental (bleedless +8 to +9). Fullness drops by about 3.5–4, so the instrumental can sound slightly thinner than with the base models. Listen before choosing.
- The difference between the two fine-tunes (0.16 dB) is not significant on 16 songs. The Mel-Roformer is about twice as fast.
- The validation references are themselves obtained by subtraction (see below), so absolute numbers are lower than on clean multitrack benchmarks; compare the models against each other.
ONNX export check
Each export was compared with the PyTorch model it came from (full songs, ONNX Runtime CUDA):
| PyTorch vs ONNX FP32 (one batch) | Inst. SDR, song A: PyTorch / FP32 / FP16 | Inst. SDR, song B: FP32 / FP16 | |
|---|---|---|---|
| BS-Roformer | −78.6 dB difference | 13.548 / 13.546 / 13.558 | 13.582 / 13.582 |
| Mel-Roformer | −75.9 dB difference | 9.724 / 9.724 / 9.724 | 15.162 / 15.175 |
Usage
pip install "onnxruntime-gpu[cuda,cudnn]" numpy soundfile # or: pip install onnxruntime numpy soundfile (CPU)
python infer_onnx.py --model bs_roformer_inst_ft_fp16.onnx --input song.wav --out_dir out/
Writes out/song_vocals.wav and out/song_instrumental.wav. Input must be 44.1 kHz (mono is duplicated to stereo). --batch sets how many 8 s chunks run at once (default 1; FP32 with batch 2 needs more than 16 GB of VRAM). --cpu forces CPU.
Speed for a 157 s song on an RTX 5060 Ti 16 GB (batch 1 for FP32, 2 for FP16):
| FP32 | FP16 | |
|---|---|---|
| BS-Roformer | 58 s | 35 s |
| Mel-Roformer | 29 s | 19 s |
ONNX interface
The graph does not contain the STFT/ISTFT; infer_onnx.py does them in NumPy.
| name | shape | layout | |
|---|---|---|---|
| input | spec |
float32 [B, 2050, 801, 2] |
stereo STFT of one chunk, frequency and channel interleaved as (freq, channel), 801 frames, real/imag |
| output | vocals |
float32 [B, 2050, 801, 2] |
masked vocal spectrogram, same layout |
- STFT:
n_fft=2048,hop=441, periodic Hann window of 2048,center=Truewith reflect padding (same astorch.stft). - Chunk: 352,800 samples (8 s at 44.1 kHz) → 801 frames. Batch size is dynamic; the frame count is fixed.
- After the model, set the DC bin to 0, then ISTFT.
- Long audio: chunks with 50 % overlap and a linear crossfade of 1/10 chunk, reflect-padded at the edges (as in ZFTurbo's Music-Source-Separation-Training
demix).
Training
Data. About 190 publicly released songs (mainly Japanese pop and vocal-synth music) paired with their officially released instrumental (off-vocal) versions, 11.5 h in total. For each pair the vocal target is vocals = mixture − aligned instrumental, so the training stems satisfy vocals + other = mixture exactly.
Alignment. For each song/instrumental pair:
- coarse time offset from a 4 kHz cross-correlation, refined at full rate on several windows (clock drift between windows is measured);
- a per-frequency transfer function H(f) is fitted from the instrumental to the mixture (STFT 4096), to absorb small EQ/mastering differences;
- a broadband gain per 0.5 s block, median-filtered and limited to 0.5–2×.
Quality filtering. Many pairs are not the same master or edit (different intro/outro, extra effects, different mix). A pair was kept only if
- the subtracted vocals agree with a pretrained vocal model's estimate (SDR ≥ 4 dB),
- in passages the pretrained model hears as vocal-free, the subtraction residual is ≤ −10 dB relative to the mixture,
- drift ≤ 4 samples and overlap ≥ 80 %.
203 of 427 candidate pairs passed. 16 were held out for validation (at most 2 per artist; other versions of those songs were removed from training by title and audio-fingerprint matching), 187 were used for training.
Fine-tuning (ZFTurbo Music-Source-Separation-Training):
| BS-Roformer | Mel-Roformer | |
|---|---|---|
| target | vocals (base head kept) | vocals (base head kept) |
| chunk | 8 s | 8 s |
| batch | 2 per GPU × 2 GPUs × grad. accumulation 2 | 2 × grad. accumulation 3 |
| optimizer | Adam, lr 1e-5, ReduceLROnPlateau (patience 3, ×0.95) | same |
| other | EMA 0.999, AMP, gradient checkpointing | EMA 0.999, AMP |
| augmentation | per-stem loudness 0.5–1.5, no mixup | same |
| steps | 1000 per epoch; early stop after 8 epochs without gain | same |
| best epoch | 5 (of 11) | 10 (of 19) |
| hardware | 2× NVIDIA L40S, ~55 min/epoch | 1× L40S, ~18 min/epoch |
Mixup was disabled so that subtracted vocals are never mixed into a different song.
Limitations
- Small validation set (16 songs); the BS vs Mel comparison is within noise.
- Training targets come from subtraction, so they contain whatever differs between the released mix and the released instrumental (and lossy-encoding noise). The models learn to remove that too, which is one reason the instrumentals are leaner (lower fullness).
- One validation song got clearly worse with the BS-Roformer fine-tune (−1.8 dB), while the rest improved; results vary by arrangement.
- 44.1 kHz stereo only.
Licenses and credits
- Mel-Roformer fine-tune: derived from KimberleyJSN/melbandroformer (MIT).
- BS-Roformer fine-tune: derived from viperx's BS-Roformer
ep_317weights as distributed in the UVR model repository; check the upstream terms before redistribution or commercial use. - Architectures: BS-RoFormer (Lu et al., 2023) and Mel-RoFormer (Wang et al., 2023); implementation from lucidrains/BS-RoFormer via ZFTurbo/Music-Source-Separation-Training.
infer_onnx.pyis provided under the MIT license.
中文說明
兩個去人聲(取伴奏)用的微調模型,ONNX 格式(FP32 與 FP16)。模型輸出人聲,伴奏 = 原曲 − 人聲。
- 訓練資料:約 190 首公開發行歌曲與其官方伴奏版的配對(共 11.5 小時)。人聲目標由原曲減去對齊後的伴奏得到;對齊包含時間偏移、逐頻率響應與分段增益修正,並用預訓練模型篩掉版本不一致的配對(427 對中保留 203 對)。
- 驗證:16 首未參與訓練的歌。伴奏 SDR:BS-Roformer 12.93 → 13.37 dB、Mel-Roformer 12.56 → 13.22 dB;人聲殘留明顯減少(bleedless +8~9),伴奏完整度略降(fullness −3.5~4)。
- 檔案:每個模型各有 FP32 與 FP16 版本;FP16 品質相同、檔案減半、速度較快,GPU 推論建議使用 FP16。
- 推論:
pip install "onnxruntime-gpu[cuda,cudnn]" numpy soundfile,然後python infer_onnx.py --model bs_roformer_inst_ft_fp16.onnx --input song.wav --out_dir out/(輸入需 44.1 kHz)。