HTDemucs-Android / README.md
aufklarer's picture
Publish Android CPU and OpenCL model exports
38d55b5 verified
|
Raw History Blame Contribute Delete
3.17 kB
metadata
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

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.

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 and HTDemucs paper describe the model. The pinned ONNX export is the source of both artifacts. See LiteRT on Android for runtime integration and Soniqo Music for the app.