Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Facebookresearch Audiocraft WatermarkSolver

From Leeroopedia
Knowledge Sources
Domains Audio_Watermarking, Training
Last Updated 2026-02-14 01:00 GMT

Overview

Concrete tool for training AudioSeal watermarking models that embed and detect imperceptible watermarks in audio provided by the AudioCraft library.

Description

WatermarkSolver extends StandardSolver to implement the complete training loop for audio watermarking models. It trains a generator (watermark embedder) and detector jointly, using adversarial losses for audio quality, detection losses for watermark presence/absence, and multi-bit message decoding losses. The solver includes crop/shuffle/pad data augmentation for localization training, evaluation with ViSQOL/SI-SNR/PESQ quality metrics, and augmentation robustness testing.

Usage

Use this solver when training AudioSeal watermarking models. It manages the full training pipeline including balanced loss optimization, audio augmentation robustness, and localization evaluation.

Code Reference

Source Location

Signature

class WatermarkSolver(StandardSolver):
    def __init__(self, cfg: DictConfig):
        """Initialize watermark solver with losses, augmentations, and model."""

    def run_step(self, idx: int, batch: torch.Tensor, metrics: dict):
        """Perform one training/valid step: embed watermark, augment, detect, compute losses."""

    def evaluate(self) -> dict:
        """Run evaluation with quality metrics, augmentation robustness, and localization."""

    @staticmethod
    def model_from_checkpoint(checkpoint_path, device="cpu") -> WMModel:
        """Load a trained watermark model from checkpoint."""

Import

from audiocraft.solvers.watermark import WatermarkSolver

I/O Contract

Inputs

Name Type Required Description
batch torch.Tensor Yes Audio batch [B, C, T]
cfg DictConfig Yes Hydra configuration with loss weights, augmentation params

Outputs

Name Type Description
metrics dict Training metrics including g_loss, d_loss, pesq, ratio1, ratio2
WMModel WMModel Trained watermark model (from checkpoint loading)

Usage Examples

Training via Dora

# WatermarkSolver is launched via Dora experiment grids
# Example: dora run solver=watermark/default

# Loading a trained model from checkpoint:
from audiocraft.solvers.watermark import WatermarkSolver

model = WatermarkSolver.model_from_checkpoint(
    'path/to/checkpoint.th',
    device='cuda'
)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment