Modulated Contrast for Versatile Image Synthesis

Fangneng Zhan, Jiahui Zhang, Yingchen Yu, Rongliang Wu, Shijian Lu

Introduction

Image-to-image translation tasks—such as converting semantic maps to realistic photos or changing a horse into a zebra—require metrics that can capture complex structural and textural similarities. Traditional pixel-wise losses (L1/L2) often fail here, producing blurry results by forcing models toward a statistical average of all possible valid outputs.

Recently, Contrastive Learning (specifically PatchNCE) has emerged as a powerful alternative. By pulling "positive" pairs (matching patches) together and pushing "negative" pairs (non-matching patches) apart, models learn more distinct features. However, standard contrastive learning treats all negative samples equally, ignoring the fact that some negatives are "harder" (more similar to the anchor) than others. This paper introduces MoNCE (Modulated Noise Contrastive Estimation), a versatile metric that adaptively re-weights negative samples to improve synthesis quality.

Methods

MoNCE addresses the limitations of "one-size-fits-all" contrastive learning through two key innovations:

1. Task-Specific Weighting

The researchers discovered that the optimal treatment of negative samples depends on whether the task is paired or unpaired:

  • Unpaired Translation: Benefits from Hard Weighting, which focuses on negatives that look like the anchor to help the model learn fine-grained distinctions.
  • Paired Translation: Surprisingly benefits from Easy Weighting. Because paired data often has overlapping distributions between positive and negative samples, pushing too hard on "hard" negatives can confuse the model and degrade performance.

2. Global Modulation via Optimal Transport (OT)

Instead of calculating weights for every image patch independently—which can lead to conflicting gradients—MoNCE treats weighting as a global optimization problem. Using the Sinkhorn algorithm, it finds an "optimal transport plan" to coordinate pushing forces collaboratively across all patches in an image. This ensures that the contrastive "budget" is distributed where it is most effective for the entire frame.

Conceptual overview of MoNCE: comparing vanilla contrastive objectives with task-specific weighted objectives and the globally modulated objective using Optimal Transport.

Key Results

MoNCE was evaluated across a wide variety of benchmarks, including Cityscapes, Horse → Zebra, and ADE20K. It consistently outperformed baseline GAN losses, Cycle-consistency losses, and vanilla PatchNCE:

  • Unpaired (Horse → Zebra): MoNCE achieved an FID score of 41.86, a significant improvement over PatchNCE (45.33) and CycleLoss (76.37).
  • Paired (ADE20K): It reached an FID of 31.62, outperforming the popular Perceptual Loss (33.68).

Visually, MoNCE-generated images show fewer artifacts and better preserve the semantic structure of the input compared to previous methods. For instance, in semantic-to-photo tasks, the generated buildings and roads are sharper and more coherent.

Qualitative comparison of image translation results across different tasks. MoNCE produces sharper results with better structural preservation compared to CycleLoss and PatchNCE.

Conclusion and Future Work

MoNCE demonstrates that modulating the contrastive objective based on task type and global image context significantly enhances image synthesis. The discovery of the "Easy Weighting" paradox for paired tasks challenges common wisdom in self-supervised learning. While the method introduces some computational overhead due to the Sinkhorn algorithm and requires careful tuning of the temperature parameter (β), its versatility allows it to be integrated into various existing frameworks to boost performance. Future research may extend this modulated contrastive approach to video synthesis and text-to-image generation.

Summary updated

BibTeX
@inproceedings{zhan2022modulated,
  author = {Fangneng Zhan and Jiahui Zhang and Yingchen Yu and Rongliang Wu and Shijian Lu},
  title = {{Modulated Contrast for Versatile Image Synthesis}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2022},
}
Figure