Instructions to use soniqo/HTDemucs-Android with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use soniqo/HTDemucs-Android with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 3,166 Bytes
38d55b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ---
license: mit
language: []
base_model: smank/htdemucs-onnx
library_name: tflite
pipeline_tag: audio-to-audio
tags:
- music-source-separation
- onnx
- litert
- android
- opencl
---
# HTDemucs for Android
FP32 music source separation for 44.1 kHz stereo audio. The model estimates
drums, bass, other instruments and vocals. The runtime can sum the first
three stems to produce an instrumental track.
| File | Format | Size | Use |
| --- | --- | ---: | --- |
| `htdemucs.onnx` | ONNX FP32 | 304,321,552 bytes | ONNX Runtime CPU |
| `separator-fused-norm.tflite` | LiteRT FP32 | 244,796,736 bytes | LiteRT OpenCL GPU |
| `LICENSE` | MIT | | License and attribution |
Both use the same original HTDemucs weights and process 7.8-second windows.
The CPU file exactly matches the pinned upstream ONNX export. The GPU export
changes tensor layouts and how the graph is executed. It uses host-side
framing, inverse STFT and overlap-add.
| SHA-256 | File |
| --- | --- |
| `d2b401f322558cd57d67a752ed7be3fa55178a0626011eda8ac7bb74e17280c0` | `htdemucs.onnx` |
| `3b4aeed464fc0ce5cde49a3404d1cb47ff64a33bc51e88f6de98eaa0fa45d445` | `separator-fused-norm.tflite` |
## Android measurements
| Samsung Galaxy S23 Ultra, 60-second clip | Elapsed | Real-time factor |
| --- | ---: | ---: |
| LiteRT OpenCL with a warm kernel cache | 20.89 s | 0.348 |
| LiteRT OpenCL with an empty kernel cache | 27.53 s | 0.459 |
These runs used LiteRT 2.3.2 with the model already on the device. Timing
includes model verification and initialization, processing and WAV export.
Warm-run peak sampled process PSS was 1.93 GiB. The five PCM16 outputs
matched the qualified FP32 LiteRT reference across 26.46 million samples.
## Download
```sh
hf download soniqo/HTDemucs-Android htdemucs.onnx
hf download soniqo/HTDemucs-Android separator-fused-norm.tflite
```
Select one export for the target runtime. The CPU export accepts one
normalized `[1, 2, 343980]` stereo float tensor. The GPU signature also takes
`[672, 4096]` reflection-padded audio frames. Its outputs are a
`[1, 16, 2048, 336]` complex spectrogram representation and a
`[1, 4, 2, 343980]` waveform tensor. Converting the spectrogram to audio
requires the original window and inverse STFT. The runtime adds the waveform
output, reverses input scaling and overlap-adds consecutive windows.
```python
from huggingface_hub import hf_hub_download
from ai_edge_litert.interpreter import Interpreter
path = hf_hub_download("soniqo/HTDemucs-Android", "separator-fused-norm.tflite")
model = Interpreter(model_path=path)
for tensor in model.get_input_details() + model.get_output_details():
print(tensor["name"], tensor["shape"], tensor["dtype"])
```
## Source
The [original Demucs implementation](https://github.com/facebookresearch/demucs)
and [HTDemucs paper](https://arxiv.org/abs/2211.08553) describe the model.
The [pinned ONNX export](https://huggingface.co/smank/htdemucs-onnx/tree/fb1fd25aa6260c253d86bbb4aa26b73aebc79f10)
is the source of both artifacts. See [LiteRT on Android](https://developers.google.com/edge/litert/android)
for runtime integration and [Soniqo Music](https://soniqo.audio/music) for the app.
|