GAN-Supervised Dense Visual Alignment

William S. Peebles, Jun-Yan Zhu, Richard Zhang, Antonio Torralba, Alexei A. Efros, Eli Shechtman · DOI

Abstract

Visual alignment is a fundamental task in computer vision, yet global joint alignment across diverse, unconstrained datasets remains challenging. We present GANgealing, a framework that leverages the latent space of a pre-trained GAN to automatically generate infinite training data for dense visual alignment. By jointly learning a "target mode" and a spatial transformer, our method achieves state-of-the-art correspondence results on complex datasets like LSUN Cats and Dogs without requiring human-provided labels.

Introduction

Finding pixel-level correspondences between images—visual alignment—is essential for tasks ranging from 3D reconstruction to video editing. While pairwise alignment has seen significant progress, global joint alignment (aligning an entire dataset to a common canonical frame) is difficult for "in-the-wild" data. Traditional methods like "Congealing" struggled with real-world complexity, and modern deep learning approaches often rely on expensive human-annotated keypoints. GANgealing addresses this by extracting geometric knowledge directly from generative models.

Methods: GAN-Supervised Learning

The core of GANgealing is using a pre-trained GAN (e.g., StyleGAN2) as a differentiable dataset to supervise a Spatial Transformer Network (STN).

The GANgealing training pipeline: A pre-trained generator $G$ produces unaligned images from random latents $w$, while a learned target latent $c$ defines the aligned pose. An STN $T$ is trained to minimize perceptual loss between the warped image and the target.

The "Mix" Trick

To train the STN, we need pairs of unaligned and aligned images. We sample a random latent code $w$ to generate an unaligned image $x = G(w)$. To create its aligned counterpart $y$, we utilize StyleGAN’s style-mixing capabilities: we combine a learned "target" latent $c$ (controlling pose and shape) with the original $w$ (controlling texture and identity). This yields an image $y$ that retains the identity of $x$ but is shifted into a standardized pose.

Joint Optimization and Multi-modal Alignment

The algorithm simultaneously trains the STN and optimizes the target latent $c$ via gradient descent. This allows the model to automatically discover the most "alignable" pose for the dataset. For multi-modal data (e.g., cars viewed from different angles), we extend this to learn $K$ target modes and $K$ corresponding STNs, using a classifier to assign images to the appropriate cluster.

Key Results

GANgealing demonstrates remarkable performance across a wide variety of challenging datasets, including LSUN (Bicycles, Cats, Cars, Dogs, Horses, TV Monitors), CelebA, and CUB-200-2011.

Qualitative results of GANgealing across various datasets. The rows show input images, congealed (aligned) images, and correspondence visualizations. The rightmost column shows the learned "Average Image" for each category.

Accuracy and Precision

On the SPair-71K benchmark, GANgealing nearly doubled the performance of previous self-supervised methods in categories like Bicycles and Cats. Notably, at high-precision thresholds (1-2 pixel error), it outperforms state-of-the-art models trained on human-labeled keypoints.

Applications

Beyond alignment, the framework enables "edit propagation," where a mask or edit applied to a single "average" image can be propagated across thousands of others. It also facilitates dataset pre-processing; aligning LSUN Cats before training a new GAN reduced the FID from 6.9 to 3.9, indicating significantly faster convergence and higher visual quality.

Discussion and Limitations

While powerful, GANgealing is bounded by the quality and diversity of the pre-trained GAN. If a GAN suffers from mode collapse, the STN cannot learn to align those missing poses. Additionally, correspondences are limited to parts visible in the learned target mode. Future work may involve using GAN inversion to allow users to define custom alignment frames for specific downstream tasks.

Summary updated

BibTeX
@inproceedings{peebles2021gan,
  author = {William S. Peebles and Jun-Yan Zhu and Richard Zhang and Antonio Torralba and Alexei A. Efros and Eli Shechtman},
  title = {{GAN-Supervised Dense Visual Alignment}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  doi = {10.1109/cvpr52688.2022.01311},
}
Figure