SynthIdImageWatermarker<T>

Models & Types · AiDotNet.Safety.Watermarking

A SynthID-Image-style post-hoc watermark. A trained encoder adds a content-dependent residual carrying a payload. A trained decoder outputs a detection logit and one logit per payload bit. Detection is a three-state decision calibrated on held-out clean and watermarked images.

Inheritance: NeuralNetworkBase<T> → StegaStampWatermarker<T> → SynthIdImageWatermarker<T>

For Beginners

one network hides a code in an image by changing it almost invisibly. A second network answers two questions: “is there a mark at all?” and “what does the code say?”. Before you trust its answer, show it many clean and many marked images. It then learns how its scores are distributed and can say “marked”, “not marked” or “not sure”, with a known error rate.

How It Works

Gowal et al. (2025) describe SynthID-Image’s objective and decision rule but not its networks, losses or training schedule, and the weights are not public. This is an open implementation of what the paper states:

  • A post-hoc encoder and decoder ⟨f, g⟩, where g returns a detection logit and per-bit payload logits.
  • Detection trained by cross-entropy, on transformed watermarked images (label 1) and the same transformations

of clean images (label 0), under a perceptual constraint.

  • A separate payload loss.
  • A mark that depends on the content, so that it cannot be lifted onto another image.
  • Conformal p-values against held-out clean and watermarked calibration sets. Thresholding both at alpha

gives a watermarked, not-watermarked or abstain verdict.

What the paper does not give comes from StegaStampWatermarker, which this class extends. The encoder is its U-Net and the decoder its spatial-transformer network, with one extra logit. The perceptual constraint is its border-weighted YUV loss plus the WGAN critic. The transformations are its differentiable warp, blur, noise, colour and JPEG distortions. Content dependence is trained with a specificity loss: one image’s residual is added to another image and labelled unwatermarked. The paper describes no such loss. Treat this as an open design of the same family, not a reproduction of Google’s system.

Decide needs Calibrate first. The guarantee is the conformal one: if a clean test image is exchangeable with the clean calibration images, P(verdict = watermarked) <= alpha. Under the same condition, a watermarked image is called not-watermarked with probability at most alpha. A level of alpha can only be reached with at least 1/alpha - 1 calibration images per set. With fewer, the decision abstains.

The keyed Detect answers a narrower question: does the image carry this key’s payload? It scores the payload logits against the key codeword’s signs. That z is exactly standard normal, given the logits, for images that do not carry the payload. A detection is reported only when that z is significant and the detection logit also agrees: the calibrated verdict is watermarked, or, before calibration, the logit is positive.

Constructors

Constructor Summary
SynthIdImageWatermarker() Creates a watermarker with SynthID-O’s stated sizes (512 x 512 images, 136 payload bits).
SynthIdImageWatermarker(SynthIdImageOptions options, string key) Creates a watermarker; key derives the payload EmbedWatermark hides.

Properties

Property Summary
bool IsCalibrated { get; } Whether Calibrate has supplied both calibration sets.
string ModuleName { get; }

Methods

Method Summary
ModelMetadata<T> GetModelMetadata()
SynthIdImageWatermarker<T> WithKey(string key) This trained watermarker under another key: the same networks and calibration, a different payload.
WatermarkDecision Decide(Tensor<T> image) The calibrated decision for image at FalsePositiveRate.
WatermarkResult Detect(Tensor<T> image) Tests image for this key’s payload.
double[] DetectionLogits(Tensor<T> images) The detection logit of each image in images, [B, 3, H, W] or [3, H, W].
void Calibrate(Tensor<T> cleanImages, Tensor<T> watermarkedImages) Records the detection-logit distributions the decision is calibrated against.