FreeCond: Free Lunch in the Input Conditions of Text-Guided Inpainting

Teng-Fang Hsiao, Bo-Kai Ruan, Sung-Lin Tsai, Yi-Lun Wu, Hong-Han Shuai · DOI

Text-guided inpainting is a powerful tool in generative AI, allowing users to modify specific regions of an image using natural language. However, existing Stable Diffusion Inpainting (SDI) models often struggle with a phenomenon known as "harmony bias." These models are trained to prioritize seamless blending with the background, which frequently leads them to ignore complex or "out-of-context" user prompts in favor of maintaining visual consistency.

FreeCond introduces a training-free, zero-computation-overhead "plug-in" that addresses these limitations by strategically modifying the input conditions during the diffusion process.

The Challenge: Harmony Bias and Mask-Fitting

Standard SDI models face two primary hurdles:

  1. Prompt-Adherence: When a prompt contradicts the surrounding context (e.g., placing a zebra in a city street), the model often defaults to context-appropriate objects (like a person in a striped shirt) rather than following the literal instruction.
  2. Mask-Fitting: Models often fail to respect the boundaries of user-provided masks, especially when those masks are rough or consist of multiple disjointed parts.
A rough, multi-part mask used to specify the location for two huskies on a bench, illustrating the challenge of mask-fitting.

The authors' investigation revealed that this bias stems from the training process, where models are exposed to random masks that encourage background preservation over strict prompt following.

The FreeCond Approach

FreeCond operates by manipulating the latent image and mask conditions during the early stages of the diffusion process. This intervention is based on the discovery of the "80 Channel" phenomenon: numerical analysis showed that the model's ability to selectively paint within a mask is concentrated in the first 80 channels of the cross-attention key features.

1. FreeCond Image Condition

To reduce "distraction" from the background, FreeCond applies a low-pass filter to the unmasked areas during the initial diffusion steps. By blurring high-frequency details like textures and sharp edges, the model is forced to rely more heavily on the text prompt to generate new structures, effectively providing a "cleaner canvas" for the desired content.

2. FreeCond Mask Condition

FreeCond scales the latent mask values to amplify the "instructional signal." By increasing the strength of the mask condition and subtly adjusting values outside the mask, the method induces a stronger feature shift in the cross-attention layers. This ensures the model "hears" the prompt more clearly within the designated area.

Universal Performance Gains

The researchers evaluated FreeCond using a new benchmark, FCIBench, designed to test complex, out-of-context prompts and varied mask types. The results demonstrate that FreeCond acts as a universal booster for diffusion-based inpainting.

Qualitative comparison of various state-of-the-art models (SD 1.5, SDXL, BrushNet, PowerPaint) with and without FreeCond. The "+FreeCond" versions show significantly better adherence to complex prompts and better mask fitting.

Key results include:

  • Significant CLIP Score Improvements: FreeCond boosted prompt-adherence scores by up to 60% for SD 1.5 and 58% for SDXL on the FCIBench.
  • Seamless Integration: The method successfully enhanced existing state-of-the-art models like BrushNet and PowerPaint, improving both their prompt-following and Intersection-over-Union (IoU) mask-fitting scores.
  • Zero Overhead: Since FreeCond only modifies input tensors during the forward pass, it requires no additional training and adds no measurable computational or memory cost.

Conclusion

FreeCond provides a "free lunch" for text-guided inpainting, offering a simple yet effective way to overcome harmony bias. By understanding and manipulating the internal mechanisms of cross-attention, it allows users to achieve high-fidelity, prompt-accurate results without the need for expensive fine-tuning. While some hyperparameter tuning may be required for specific images, FreeCond represents a significant step forward in making diffusion models more responsive to human intent.

Summary updated

BibTeX
@inproceedings{hsiao2026freecond,
  author = {Teng-Fang Hsiao and Bo-Kai Ruan and Sung-Lin Tsai and Yi-Lun Wu and Hong-Han Shuai},
  title = {{FreeCond: Free Lunch in the Input Conditions of Text-Guided Inpainting}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2026},
  doi = {10.1109/wacv61042.2026.00533},
}
Figure