Abstract
Text-to-image diffusion models often struggle with "content leakage" during style transfer, where unwanted objects from a style reference image bleed into the generated output. We introduce a simple, training-free masking technique that zeroes out content-related elements in the image feature vector. By demonstrating that "less is more," we show that dropping specific features effectively decouples style from content, leading to superior style transfer without aesthetic degradation. Our method achieves significant improvements in human preference scores and text fidelity across multiple benchmarks.
Introduction
Imagine generating an image of a cat using the visual style of a watercolor painting of a dog. Ideally, the model produces a watercolor cat. However, current text-to-image diffusion models often suffer from content leakage, resulting in hybrid images where the "dog" content from the reference bleeds into the "cat" prompt. This occurs because models struggle to disentangle style from content within image embeddings.
Previous solutions typically involve expensive retraining on massive datasets or training-free "hacks" like feature subtraction (e.g., the InstantStyle method). However, subtracting text features from image features often causes "modality misalignment." Because text and image embeddings do not map perfectly to one another, this subtraction can destroy the intended style information, leading to outputs that lack the desired aesthetic.
Methodology
To address this without additional training or cross-modality clashes, we propose a masking-based method operating entirely within the image feature space. Instead of subtraction, we simply "turn off" the components of the image feature representing unwanted content. The process follows five steps:
- Extraction: Extract the image feature of the style reference and the text feature of its content (e.g., "dog").
- Interaction: Compute the element-wise product of these two feature vectors.
- Clustering: Group these products using a simple K-means clustering algorithm.
- Identification: Identify the cluster with the highest values, representing elements most strongly correlated with the unwanted content.
- Masking: Zero out these elements in the original image feature vector before passing it into the diffusion model's cross-attention layers.
Experimental Setup
We evaluated our method using two primary benchmarks:
- Custom Evaluation Dataset: To precisely measure leakage, we built a dataset using 10 object classes from CIFAR-10 rendered in 21 distinct styles (via the MACE framework), totaling 880 style references.
- StyleBench: A standard benchmark containing 73 distinct styles, ranging from 3D models and illustrations to classical paintings.
Key Insights
"Less is More"
The most significant finding is that providing the diffusion model with fewer conditions improves performance. By dropping specific image feature elements, the model achieves a smaller mathematical divergence between the generated image distribution and the target real image distribution.
Mathematical Efficiency
We prove that masking based on the element-wise product maximizes the "energy score" for the unwanted content text. This is the most mathematically efficient way to isolate and trap unwanted subject matter compared to simple absolute difference metrics.
Robustness
Unlike methods like IP-Adapter or InstantStyle, which require users to painstakingly tweak the "weight" of the image prompt, our masking approach is robust enough to work with a fixed weight of 1.0, significantly reducing the need for manual trial and error.
Results
Qualitative comparison showing our method successfully transferring style without content leakage across various prompts and references. Less is More: Masking Elements in Image Condition Features Avoids Content Leakages in Style Transfer Diffusion Models, page 1
Quantitative Performance
On our custom dataset, the masking method achieved a 36.7% Human Preference score, significantly outperforming the next best state-of-the-art method, StyleShot (24.3%). It also achieved a near-perfect text fidelity score (0.972) and the lowest content leakage score (0.478). On StyleBench, the method scored 42.1% Human Preference, doubling the performance of the runner-up.
Qualitative Excellence
Visually, the model applies complex styles—such as specific brushstrokes or neon lighting—to new prompts without bringing over the original subjects. For instance, as shown in the comparison above, a woman's portrait can serve as a style reference for an "ancient temple" or "laptop" without her facial features leaking into the final architecture or hardware.
Conclusion and Future Work
While highly effective, the optimal number of clusters ($K$) can vary. Smaller $K$ values (masking more features) work best for human-heavy styles like Anime or Baroque to aggressively prevent facial leakage but may be too aggressive for simpler styles. Future work will explore automated $K$ selection. Additionally, we emphasize the need for responsible use, as the ability to transfer styles involving human attributes carries risks of reinforcing stereotypes if not managed carefully.
Summary updated