HTDemucs (ONNX, compact graph for DirectML)
The pretrained htdemucs model from Meta's Demucs
(MIT licence), exported to ONNX for use in a karaoke player's vocal removal.
Input mix: [1, 2, 343980] float32, 44.1 kHz stereo (7.8 s segment).
Output stems: [1, 4, 2, 343980] in the order drums, bass, other, vocals.
Why another export
Common ONNX exports of HTDemucs unroll the inverse STFT into a chain of hundreds of
ScatterND operations (about 24,700 operations in total). CPUs cope, but DirectML keeps
every intermediate buffer alive and a 12 GB RTX 3060 runs out of memory ("not enough memory
resources", then a GPU hang).
In this export the STFT is one convolution against the windowed DFT basis, and the inverse is
one matrix multiply plus four shifted additions: 4,631 operations, no ScatterND.
On real music it matches the original PyTorch model to about -110 to -125 dB RMS error.
On the test PC it runs on DirectML in about 12 s for a 3:40 song, using about 2 GB of video
memory (the processor takes about 2 minutes).
The export script is scripts/export_htdemucs_onnx_dml.py in the Ferrite/Karaoke project.
Credit
Model and weights: Défossez et al., Meta AI Research, Hybrid Transformers for Music Source Separation. MIT licence.
SHA256 of htdemucs-dml.onnx: 9e06fef2b23e0f772c6a0cedc4da3aeacb066fa2fa7b6bf70ba08bb1db6220ab