Privacy-First Attribute Preserving Face Anonymization via ID-Augmented Contrastive Learning

Lun Huang, J. Matias Di Martino, Guillermo SapiroInfPriv @ NeurIPS 2026

TL;DR

How do you anonymize someone's face in a photo or video without erasing their smile, gaze, or head tilt? This paper trains an attribute encoder using self-supervised contrastive learning—pairing a face with its identity-swapped variants as positives, and other real photos of the same person as negatives—to strip away lingering identity cues. A latent diffusion model then inpaints the face, letting users dial a single knob at inference to either match a donor's face or actively push away from the original person's identity.

What Problem Does This Paper Address?

In medical and behavioral studies, researchers often need to share recordings of people smiling, frowning, or turning their heads, while protecting the subject's identity. Standard face-swapping tools offer a tempting shortcut, but they are imperfect: a swapped face often retains parts of the original person's face shape or subtly alters the curvature of a smile. If you train an anonymization model directly on those swapped outputs, it inherits both flaws—leaking identity while distorting the very expressions you wanted to preserve.

Methods

The authors tackle this in two stages: learning a clean attribute representation, and using it to condition a diffusion model.

Figure 1: One training example. In the left box, the upper synthetic portrait is xtar. Its dashed arrow leads to the attribute map used by the denoiser. Here the real portrait x is the reconstruction target xgt. Another real portrait of the same person, xsrc (bottom right), supplies the ArcFace key. The pooled features above the denoiser are used for the contrastive loss.
  • Contrastive Attribute Learning (with Same-ID Negatives): Starting with a real photograph $x$, the authors use an off-the-shelf face swapper (InSwapper) to swap in $k=4$ different donor identities. Together with $x$, these five images form a positive set—they share roughly the same expression, pose, and lighting, but have different identities. The clever twist is the negative set: other real photographs of the same person (drawn from the same ArcFace identity cluster). Because any residual identity cue—like a persistent face contour left behind by the imperfect swapper—also appears in these negatives, the encoder is forced to ignore it and rely on true attribute cues, such as how wide the mouth is open. They train this masked attribute encoder using SSOLE (self-supervised orthogonal low-rank embedding), where a low-rank term pulls the positive set into a common subspace and an orthogonality term separates features across the same-ID negatives.
  • Diffusion Inpainting & Inference-Time Guidance: A latent diffusion model (initialized from Stable Diffusion) inpaints the masked face, conditioned on the background, the mask, the spatial attribute map, and an ArcFace identity vector via cross-attention. At inference, a guidance scale $s$ controls identity: positive $s$ steers the generation toward a donor's face (swapping), while negative $s$ combines a donor-conditioned prediction with a repulsive term keyed to the original subject (anonymization).

Datasets

  • Training: CelebA-HQ, CelebRef-HQ, and FFHQ, clustered via ArcFace embeddings into 5,497 training clusters and 316 validation clusters.
  • Evaluation: 1,000 source–target pairs from FFHQ at $512 \times 512$ resolution.

Key Insights and Ideas

  • Same-ID negatives clean up imperfect swaps: Using other photos of the same person as negatives might sound counterintuitive, but it acts as a filter—teaching the attribute encoder to discard residual identity cues (like face shape) that an imperfect swapper fails to erase.
  • One model, two modes: Because identity guidance is applied at inference, the exact same trained model can either swap in a donor's face ($s > 0$) or suppress the original identity ($s < 0$) without retraining.
  • Pose holds steady even when local details shift: Under strong negative guidance, local facial details can change (for instance, narrowing the eyes or showing more teeth), yet global head orientation remains accurate.

Key Results

  • The anonymization–attribute trade-off: On 1,000 FFHQ test pairs, dialing negative guidance from $s = -0.8$ to $s = -1.5$ drops mean target ArcFace similarity from $0.17$ down to $0.04$ (stronger anonymization), while pose error rises modestly from $2.72^\circ$ to $2.92^\circ$ and expression error increases from $0.95$ to $1.01$.
  • Comparison to baselines: At $s = -0.8$, the model achieves lower FID ($6.42$), lower target similarity ($0.17$), and lower expression error ($0.95$) than both REFace and InSwapper.
  • Encoder ablation: Adding same-ID negatives to SSOLE improves FID from $6.14$ to $5.16$ and pose error from $3.46^\circ$ to $3.35^\circ$, while keeping expression error steady at $1.01$.
Figure 2: Swapping and anonymization on FFHQ. Read each row from the target portrait and masked background through the donor face, the two baselines, and our outputs. The target supplies pose and expression in both output columns.

Limitations and Future Work

  • Shared embedding space: ArcFace defines the training clusters, identity keys, and evaluation similarity metric. Testing with an independent face recognizer (e.g., top-1 gallery retrieval) and probing frozen attribute features for surviving identity cues would provide a stricter privacy check.
  • Full-image FID vs. face crops: Full-image FID includes the unedited background, which can mask implausible face boundaries; evaluating on aligned face crops would better isolate face quality.
  • Context outside the mask: Hair, glasses, clothing, and background context remain outside the inpainted mask and can still help identify the subject.

Summary updated

BibTeX
@inproceedings{huang2026privacy,
  author = {Lun Huang and J. Matias Di Martino and Guillermo Sapiro},
  title = {{Privacy-First Attribute Preserving Face Anonymization via ID-Augmented Contrastive Learning}},
  booktitle = {InfPriv @ NeurIPS},
  year = {2026},
  url = {https://openreview.net/forum?id=6PnyJl2F5m},
}
Figure