perth-onnx / README.md
gotham13's picture
Perth watermarker as ONNX, with the export script and parity results
1c22fd5 verified
|
Raw History Blame Contribute Delete
2.13 kB
---
license: mit
library_name: onnx
base_model: resemble-ai/Perth
tags:
- audio-watermarking
- perth
- onnx
inference: false
---
# Perth (implicit) watermarker, ONNX
An ONNX export of Resemble AI's [Perth](https://github.com/resemble-ai/Perth) implicit watermarker, as shipped in
the `resemble-perth` 1.0.1 package (checkpoint `perth_net_250000.pth.tar`, SHA-256
`a15bce457ebc53ce5e6c9c3f11df78cf7ee2bf9cdab0a798902135b4c4027670`). The weights are unchanged. This is not an
official Resemble AI release.
Perth adds an imperceptible watermark to the magnitude spectrum below 2 kHz and detects it from the whole clip.
## Files
| File | Input | Output |
| --- | --- | --- |
| `perth_embed.onnx` | `audio`: float32 `[T]`, mono, 32 kHz | `audio_marked`: float32 `[320 * (T // 320)]` |
| `perth_detect.onnx` | `audio`: float32 `[T]`, mono, 32 kHz | `score`: float32 `[1]`, 0 to 1 (about 1 when marked) |
Both graphs are opset 18 and contain the whole pipeline: STFT (2048 points, hop 320, Hann window), the network,
and for the embedder the inverse STFT. `torch.istft` does not export to ONNX, so the embedder uses an equivalent
built from matrix products, reshapes and pads (`OnnxISTFT` in the script; at most 1.5e-6 from `torch.istft`).
Resample other rates to 32 kHz first.
## Parity with the PyTorch original
`export_watermarkers.py perth OUT clip.wav ...` exports the graphs and compares them with
`perth.PerthImplicitWatermarker` (`apply_watermark`, `get_watermark(round=False)`), torch 2.15 on CPU, on two
speech clips (11.8 s and 4.1 s) resampled to 32 kHz:
| | 11.8 s clip | 4.1 s clip |
| --- | --- | --- |
| embedded audio, max abs difference (PyTorch vs ONNX) | 5.4e-7 | 5.1e-7 |
| unmarked clip, score PyTorch / ONNX | 5.1e-5 / 5.3e-5 | 6.5e-5 / 6.4e-5 |
| marked by PyTorch, score PyTorch / ONNX | 1.0 / 1.0 | 1.0 / 1.0 |
| marked by ONNX, score PyTorch / ONNX | 1.0 / 1.0 | 1.0 / 1.0 |
`parity.json` has the exact numbers.
## Licence and attribution
MIT, Copyright (c) 2025 Resemble AI (see `LICENSE`, the licence of the `resemble-perth` package that contains the
weights). The export script is MIT as well.