Patch-wise Graph Contrastive Learning for Image Translation

Chanyong Jung, Gihyun Kwon, Jong Chul Ye · OpenReview

Abstract

Recently, patch-wise contrastive learning is drawing attention for the image translation by exploring the semantic correspondence between the input and output images. To further explore the patch-wise topology for high-level semantic understanding, here we exploit the graph neural network to capture the topology-aware features. Specifically, we construct the graph based on the patch-wise similarity from a pretrained encoder, whose adjacency matrix is shared to enhance the consistency of patch-wise relation between the input and the output. Then, we obtain the node feature from the graph neural network, and enhance the correspondence between the nodes by increasing mutual information using the contrastive loss. In order to capture the hierarchical semantic structure, we further propose the graph pooling. Experimental results demonstrate the state-of-art results for the image translation thanks to the semantic encoding by the constructed graphs.

Introduction

Image-to-image (I2I) translation tasks, such as converting a horse to a zebra or a map to a satellite view, require a delicate balance between altering the visual style and preserving the underlying content. Traditional methods often rely on pixel-wise or patch-wise losses. Recent advancements, like the Contrastive Unpaired Translation (CUT) model, utilize patch-wise contrastive learning to maintain semantic correspondence. However, these methods often treat patches as independent entities, neglecting the rich structural and semantic relationships—or "topology"—between different parts of an image.

This work introduces a novel framework that leverages Graph Neural Networks (GNNs) to capture these topological relationships. By representing an image as a graph of patches, the model can understand context, such as the relationship between a horse's eye and its ear, ensuring that the translated output remains structurally coherent and semantically consistent with the input.

Methodology

The proposed framework, Patch-Wise Graph Contrastive Learning, consists of several key components designed to make the translation process topology-aware.

Graph Construction and Shared Adjacency

The process begins by sampling $N$ image patches, which serve as nodes in a graph. The edges between these nodes are defined by the cosine similarity of their features, extracted via a pre-trained and frozen encoder $E$. A critical innovation is the use of a Shared Adjacency Matrix. The graph structure (adjacency matrix $A$) is computed from the input image and then directly applied to the output image's graph. This enforces a structural prior, compelling the output to mirror the relational "skeleton" of the input.

The overall architecture (a) and the conceptual consistency of patch-wise connections (b).

Topology-Aware Feature Extraction

To process these graphs, the authors employ a Topology Adaptive Graph Convolutional Network (TAGCN). Unlike standard convolutions that operate on fixed grids, the GNN aggregates features from $L$-hop neighbors. This allows each patch's representation to be informed by its local neighborhood, creating features that are inherently aware of the surrounding context.

Top-K Graph Pooling

To focus the model on task-relevant regions and filter out background noise, a learnable Graph Pooling layer is introduced. This layer assigns scores to nodes and selects the top-$K$ most relevant ones. This mechanism acts as a node-wise attention system, prioritizing semantically important features (e.g., the body of an animal) over irrelevant background elements (e.g., grass or sky).

The Top-K Graph Pooling mechanism, which selects and weights the most task-relevant nodes.

Contrastive Learning Objective

The model is trained by maximizing the Mutual Information (MI) between corresponding nodes in the input and output graphs using an InfoNCE loss ($L_{GNN}$). This is combined with a standard GAN loss ($L_{GAN}$) to ensure visual realism.

Experiments and Results

The framework was evaluated on several standard benchmarks, including horse $\rightarrow$ zebra, summer $\rightarrow$ winter, and semantic label $\rightarrow$ photo tasks.

Quantitative Performance

The proposed method consistently outperformed state-of-the-art baselines such as CUT, CycleGAN, and NEGCUT. It achieved superior scores in Fréchet Inception Distance (FID) and Kernel Inception Distance (KID) across nearly all tasks. For instance, in the apple $\rightarrow$ orange translation, the model reached an FID of 139.1, a significant improvement over CUT's 171.5.

Qualitative Analysis

Visual inspections reveal that the topology-aware approach preserves fine structural details much better than previous methods. In animal translation tasks, spatial-specific patterns like dark muzzles or stripe orientations are more accurately rendered. In landscape translations, complex structures like tree branches remain coherent, avoiding the distortions common in non-topological models.

Key Insights

  • Generalization of Contrastive Learning: The authors demonstrate that their method is a generalization of standard patch-wise contrastive learning. If the number of GNN hops ($L$) is set to zero, the model effectively reverts to a point-wise matching scheme like CUT.
  • Attention via Pooling: The graph pooling layer naturally learns to highlight primary objects. This "focused view" is instrumental in improving translation quality by reducing the influence of noisy background patches.
  • Structural Consistency: Forcing the output to inherit the input's adjacency matrix provides a powerful mathematical constraint that prevents the model from "breaking" the semantic relationships between image parts during the style transfer process.

Conclusion

This paper presents a significant step forward in image-to-image translation by introducing topology-aware features through GNNs. While the approach introduces some computational overhead and requires careful hyperparameter tuning (e.g., for the similarity threshold and number of hops), the gains in structural integrity and semantic consistency are substantial. Future work may extend this graph-based paradigm to video translation or other hierarchical semantic tasks.

Summary updated

BibTeX
@inproceedings{jung2024patch,
  author = {Chanyong Jung and Gihyun Kwon and Jong Chul Ye},
  title = {{Patch-wise Graph Contrastive Learning for Image Translation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2024},
  url = {https://openreview.net/forum?id=CcWSaPuXIa},
}
Figure