DeepFilterNet3 (ONNX)

ONNX export of the DeepFilterNet3 pretrained model, converted from the PyTorch checkpoint with the upstream export script.

This is an unofficial conversion by a third party. It is not published by the DeepFilterNet authors.

Usage

The ONNX files contain only the network. DeepFilterNet3Onnx.py in this repository adds the rest in numpy: STFT, ERB features, normalisation, ERB mask and deep filtering. It needs no PyTorch, and no df or libdf packages.

pip install numpy onnxruntime soundfile huggingface_hub
import soundfile as sf
from DeepFilterNet3Onnx import DeepFilterNet3Onnx

model = DeepFilterNet3Onnx("SayedShaun/DeepFilterNet3-onnx")  # downloads the files on first use
audio, sr = sf.read("noisy.wav", dtype="float32")            # mono, 48 kHz
if audio.ndim > 1:
    audio = audio[:, 0]
enhanced = model.enhance(audio, sr=sr)                       # processes the whole file in one pass
sf.write("enhanced.wav", enhanced, sr)

DeepFilterNet3Onnx also accepts a local folder containing these files. The input must be 48 kHz mono. Processing is not streaming.

Verified: on upstream's assets/noisy_snr0.wav (508,591 samples), the output of this class, run from the Hub repo in an environment with no torch, df or libdf, matches upstream's PyTorch enhance() with the same checkpoint to within a maximum absolute difference of 3.1e-5 (signal RMS 0.055). Each stage (STFT, ERB widths, synthesis) also matches libDF to float32 precision.

Files

  • enc.onnx: encoder
  • erb_dec.onnx: ERB decoder
  • df_dec.onnx: deep-filter decoder
  • DeepFilterNet3Onnx.py: numpy pre- and post-processing and the DeepFilterNet3Onnx class
  • config.ini: model configuration from the checkpoint
  • version.txt: model name and epoch
  • SHA256SUMS.txt: checksums of the files above

Verification

The three ONNX models were run with ONNX Runtime on the input tensors saved during export, and compared with the PyTorch outputs. The maximum absolute difference was 4.8e-6 (encoder), 6.3e-7 (ERB decoder) and 1.2e-7 (DF decoder).

Compared with upstream's DeepFilterNet3_onnx.tar.gz, the sizes of the three ONNX files are within a few kilobytes of upstream's. The bytes are not identical, which is expected for a different PyTorch and ONNX version. Upstream's archive is the reference if you need the exact upstream files.

License

The code and model weights of DeepFilterNet are dual-licensed under the MIT License or the Apache License, Version 2.0, at your option. The license texts are included as LICENSE-MIT and LICENSE-APACHE. Copyright (c) 2021 Hendrik Schröter (per the upstream MIT license).

Upstream license statement: https://github.com/Rikorose/DeepFilterNet#license

Downloads last month
28
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support