Abstract
In image-to-image translation, each patch in the output should reflect the content of the corresponding patch in the input, independent of domain. We propose a straightforward method for doing so – maximizing mutual information between the two, using a framework based on contrastive learning. The method encourages two elements (corresponding patches) to map to a similar point in a learned feature space, relative to other elements (other patches) in the dataset, referred to as negatives. We explore several critical design choices for making contrastive learning effective in the image synthesis setting. Notably, we use a multilayer, patch-based approach, rather than operate on entire images. Furthermore, we draw negatives from within the input image itself, rather than from the rest of the dataset. We demonstrate that our framework enables one-sided translation in the unpaired image-to-image translation setting, while improving quality and reducing training time. In addition, our method can even be extended to the training setting where each “domain” is only a single image.
1. Introduction
Unpaired image-to-image (I2I) translation aims to learn a mapping between two visual domains—such as horses and zebras—without the benefit of corresponding image pairs in the training set. For several years, the dominant paradigm for this task has been CycleGAN, which relies on the principle of "cycle-consistency." This principle posits that if an image is translated from domain A to domain B and then back to domain A, the result should be identical to the original input.
While effective, cycle-consistency assumes a bijective (one-to-one) mapping between domains. This assumption is often too restrictive; for instance, when translating a horse to a zebra, the zebra's stripes may obscure specific muscle details of the horse, making a perfect reconstruction impossible. Furthermore, CycleGAN requires training two separate generators and two discriminators, leading to high computational costs and memory requirements. This paper introduces CUT (Contrastive Unpaired Translation), a framework that maintains content correspondence without requiring the ability to invert the transformation.
2. The CUT Framework
Instead of relying on a cycle loss, CUT employs a "one-sided" translation method rooted in Contrastive Learning. The goal is to maximize the mutual information between corresponding patches of the input and output images, ensuring that the output preserves the structural content of the input while adopting the style of the target domain.
Patchwise Contrastive Loss (InfoNCE)
The core of the framework is the Patchwise Contrastive Loss. For a given "query" patch in the output image (e.g., a zebra's ear), the model identifies a "positive" patch at the same spatial location in the input image (the horse's ear). It then samples numerous "negative" patches from different locations within the same input image. The model learns an embedding space where the query and positive patches are pulled together, while the query and negative patches are pushed apart.
Key Design Choices
- Internal Negatives: By drawing negatives from within the same image rather than the entire dataset, the model focuses on the specific structural nuances of the current scene, facilitating better disentanglement of content and style.
- Multilayer Features: The contrastive loss is not applied directly to pixels. Instead, images are passed through an encoder, and features are extracted from multiple layers. This ensures that correspondence is maintained at various scales, from low-level edges to high-level semantic concepts.
- CUT vs. FastCUT: The authors provide two versions: CUT, which includes an additional "identity loss" for increased stability, and FastCUT, a lightweight version that prioritizes speed by dropping the identity loss.
3. Experiments and Results
The framework was evaluated across several standard benchmarks, including Horse $\rightarrow$ Zebra, Cat $\rightarrow$ Dog (AFHQ), and Cityscapes (semantic labels to street photos).
Quantitative and Qualitative Performance
CUT significantly outperforms CycleGAN and other baselines in both quality and efficiency:
- Accuracy: On the Cityscapes dataset, CUT achieved a 24.7 mAP (Mean Average Precision), compared to CycleGAN’s 20.4.
- Visual Fidelity: On the Horse $\rightarrow$ Zebra task, CUT achieved an FID score of 45.5 (lower is better), a marked improvement over CycleGAN’s 77.2.
- Efficiency: CUT is approximately 40% faster and 31% more memory-efficient than CycleGAN. FastCUT offers an even more dramatic 63% speedup.
- Single-Image Translation: Remarkably, the method can translate high-resolution images using only a single source and target image, a scenario where traditional methods typically fail or produce significant artifacts.
4. Discussion and Conclusion
By moving away from the restrictive bijection of cycle-consistency and embracing patch-based contrastive learning, CUT provides a more flexible and theoretically sound approach to unpaired image translation. The results demonstrate that maximizing mutual information is sufficient for preserving content across domains.
While the model can occasionally suffer from semantic misalignment (e.g., applying textures to the background in unusual poses) or minor hallucinations, its efficiency and performance make it a powerful new tool for conditional image synthesis. Future work may extend this patch-based contrastive approach to other domains, such as video-to-video translation or text-to-image synthesis.
Summary updated