# Local neural separation

Imagine STEM uses ONNX Runtime Web 1.23.2 (Microsoft, MIT) with the standard four-source HTDemucs model exported by StemSplit. Application UI, download/cache/cancellation handling and integration code are original. The tensor layout and chunked overlap-add follow the model author's documented reference. No Solderless application code is copied.

- Runtime: https://github.com/microsoft/onnxruntime/tree/v1.23.2/js/web
- Runtime license: https://github.com/microsoft/onnxruntime/blob/v1.23.2/LICENSE
- Export implementation and browser specification: https://github.com/StemSplit/demucs-onnx
- Reference inference: https://huggingface.co/StemSplitio/htdemucs-onnx/blob/d54ed9eb60e258ea82131c6ee14578628816456a/infer.py
- Model card and MIT declaration: https://huggingface.co/StemSplitio/htdemucs-onnx/blob/d54ed9eb60e258ea82131c6ee14578628816456a/README.md
- Original model: https://github.com/facebookresearch/demucs

Pinned model: `htdemucs_fp16weights.onnx`, revision `d54ed9eb60e258ea82131c6ee14578628816456a`, 165,612,636 bytes, SHA-256 `d05c269d0178d2a72ad484b10b11dd370193fc923201c3b27a99f848745db70a`. The smaller stored weights are converted to float32 computation by the graph. This is the all-four-source model, not the vocals-only fine-tuned specialist.

Audio is decoded/resampled locally to stereo 44.1 kHz, processed in fixed 343,980-frame windows, and resampled/cropped to aligned stereo 48 kHz output. Channel order is Drums, Bass, Other, Vocals. No per-stem normalization occurs. A single common attenuation is applied only if predicted output exceeds digital full scale, preserving the relative stem mix while avoiding PCM clipping. BPM defaults to 80 and must be set by the user.

Inference runs on single-threaded CPU WASM in a dedicated worker. Cancel terminates the worker, including an in-flight inference. Model fetch is bounded, progress-visible and checked against pinned size and SHA-256. Cache Storage is best effort; offline reuse requires the cache to survive, and the web app/runtime themselves must also be available. Audio is never uploaded. Initial model download requires internet. Separation supports mono/stereo songs up to 8 minutes and source files below 100 MB; desktop memory and CPU speed still matter. Source separation is approximate and can leave bleed/artifacts.

## Actual numerical verification

On 22 October 2026, the pinned model was downloaded and its size/SHA-256 verified. An actual ONNX Runtime Web 1.23.2 single-threaded WASM inference ran in Node on six seconds of original synthesized tones/pulses, zero-padded to the model window. Model initialization took 6.21 seconds and inference took 17.54 seconds on this Mac. The result had shape `[1, 4, 2, 343980]`; all values were finite and all four predictions differed. Stem RMS values were approximately `[0.0000800, 0.1072645, 0.0112191, 0.0000339]`. Summing the predictions reconstructed the generated left channel with 0.455% relative RMS error. This proves real inference execution, not stem quality on a commercial recording or successful hardware transfer.

The `all` graph optimization setting aborted in this WASM runtime during initialization. The tested path uses `graphOptimizationLevel: 'disabled'` with arena/memory-pattern reuse enabled. Separate browser verification also passed: a two-second generated mix produced four stems, previewed and transferred with a second song through the simulator. Cache reuse and cancellation were exercised. The production worker completed another real inference with its local web server stopped, using cached runtime assets and model.

To reproduce from the project directory, run `node third_party/separation-smoke.mjs`. It downloads the pinned model into `.cache/` if missing, verifies size and SHA-256, then runs actual neural inference on locally generated six-second signals. The model download has a 3-minute bound. Alternatively pass an existing model path: `node third_party/separation-smoke.mjs /path/to/htdemucs_fp16weights.onnx`. No machine-specific path is required by the script. It exits nonzero for a bad checksum, unexpected shape, non-finite output, duplicated/empty predictions, or reconstruction error above 10% on the generated fixture. A 10% test threshold is deliberately a gross failure check, not a promise of source-separation fidelity on arbitrary music.

## License notices

MIT License

Copyright (c) 2026 StemSplit

Copyright (c) Meta Platforms, Inc. and affiliates.

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
