File size: 3,627 Bytes
fd3221a
 
 
 
ce5cf6e
fd3221a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bb67c90
fd3221a
 
 
d05f5e0
 
02c7390
d05f5e0
 
02c7390
d05f5e0
 
 
 
02c7390
 
 
 
 
 
 
 
d05f5e0
 
02c7390
 
 
d05f5e0
fd3221a
 
 
 
 
02c7390
fd3221a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: other
license_name: mit-or-apache-2.0
license_link: https://github.com/Rikorose/DeepFilterNet/blob/main/LICENSE-MIT
pipeline_tag: audio-to-audio
tags:
  - audio
  - speech-enhancement
  - denoising
  - onnx
  - deepfilternet
---

# 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.

- **Original author:** Hendrik Schröter and the DeepFilterNet contributors
- **Upstream project:** https://github.com/Rikorose/DeepFilterNet
- **Source checkpoint:** `DeepFilterNet3.zip` from upstream commit `82b0c7ad33fc756284104053817d1e855d8d8386` (https://github.com/Rikorose/DeepFilterNet/blob/main/models/DeepFilterNet3.zip). Checkpoint epoch 120.
- **Export script:** `df/scripts/export.py` from upstream commit `7b14b895fe7fc42cab72b4a4c1e49c982bd6404b` (2026-11-06), run with default options: opset 12, no simplification, no post-filter.
- **Versions:** PyTorch 2.2.2 (CPU), ONNX 1.23.2, ONNX Runtime 1.32.0.

## 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.

```sh
pip install numpy onnxruntime soundfile huggingface_hub
```

```python
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