Comparison Reveals Commonality: Customized Image Generation through Contrastive Inversion

Minseo Kim, Minchan Kwon, Dongyeun Lee, Yunho Jeon, Junmo KimarXiv 2025 · DOI

Abstract

Personalizing text-to-image (T2I) models to generate specific concepts from a few reference images—known as customized generation—frequently suffers from an "overfitting vs. editability" trade-off. Models often fail to disentangle the target subject from its background or pose, leading to poor prompt alignment. We introduce Contrastive Inversion, a framework that isolates a target concept ($S^*$) by shunting image-specific "noise" into auxiliary tokens ($A^*_i$) via contrastive learning. This process, combined with a disentangled cross-attention fine-tuning mechanism, enables high-fidelity image generation that remains highly responsive to text prompts without requiring manual masks or captions.

Introduction

Customized generation allows users to teach a model a specific concept, such as a personal pet, from just 3–5 photos. However, existing methods like Textual Inversion or DreamBooth often struggle with entanglement. If a subject is consistently photographed in a specific setting (e.g., a dog on a red rug), the model may incorrectly incorporate the setting into the concept's definition. This results in "background bleed," where the model fails to generate the subject in new contexts (e.g., "the dog in space") or different poses.

Traditional solutions involve manual intervention, such as drawing masks or writing detailed captions, which is labor-intensive and often fails to capture subtle visual nuances. Contrastive Inversion addresses this by automating disentanglement through the principle that "comparison reveals commonality."

Methodology

The proposed framework operates in two primary stages:

1. Contrastive Inversion

Instead of learning a single token for the target subject, the model learns a shared target token ($S^*$) and a unique auxiliary token ($A^*_i$) for each training image. A contrastive loss (InfoNCE) is employed to ensure that auxiliary tokens capture only the features unique to their respective images (e.g., specific lighting or background). By penalizing auxiliary tokens that overlap with other images, the shared target token is forced to represent only the common elements—the subject itself.

2. Disentangled Cross-Attention Fine-tuning

To enhance fidelity, the U-Net’s cross-attention layers are fine-tuned. The architecture duplicates the Key ($K$) and Value ($V$) projection matrices. One set is dedicated to the target token ($S^*$), while the auxiliary set handles the image-specific tokens ($A^*_i$).

Crucially, during inference, the auxiliary attention pathways are discarded. This ensures that the final generation is driven solely by the "clean" target concept, effectively filtering out the background noise learned during training.

Experimental Evaluation

The method was evaluated on DreamBench, a standard dataset for personalized generation containing 30 subjects and 25 diverse prompt templates. Performance was measured using DINOv2 for subject fidelity and CLIP-T for prompt alignment.

Key Results

Contrastive Inversion demonstrates a superior balance between fidelity and editability compared to baselines like DreamBooth and Custom Diffusion.

  • Quantitative: It achieved a DINOv2 score of 0.530, matching state-of-the-art methods like DisenBooth while providing better prompt alignment.
  • Qualitative: The model excels in complex re-contextualization tasks. For instance, in "shape-shifting" prompts (e.g., "a cube-shaped teapot"), Contrastive Inversion successfully modifies the subject's geometry while preserving its unique textures, whereas other models often lose the subject's identity or ignore the prompt.

Discussion and Insights

The "sink" strategy is central to this approach: by providing a dedicated space (auxiliary tokens) for unwanted information, the model naturally purifies the target token. Unlike previous methods, this approach is guidance-free, requiring no pre-defined class nouns or external image embeddings.

Limitations

The framework's effectiveness depends on the diversity of the input images. If the subject is in the same pose in every photo, that pose may be baked into the target concept. Additionally, featureless backgrounds provide a weak contrastive signal, making disentanglement more challenging.

Conclusion

Contrastive Inversion offers a robust, automated solution for personalized image generation. By leveraging contrastive learning to separate commonality from auxiliary noise, it achieves high-fidelity results that are remarkably easy to edit, paving the way for more intuitive and powerful customized AI generation tools.

Summary updated

BibTeX
@misc{kim2025comparison,
  author = {Minseo Kim and Minchan Kwon and Dongyeun Lee and Yunho Jeon and Junmo Kim},
  title = {{Comparison Reveals Commonality: Customized Image Generation through Contrastive Inversion}},
  year = {2025},
  eprint = {2508.07755},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.07755},
}
Figure