Negative-attention-for-ComfyUI-

Negative-attention-for-ComfyUI-
★ 9

交叉注意力负向条件差分适配SDXL/SD1.X不支持Flux
在cross-attention中对正向与负向条件取差分,产生负向影响但不生成负向预测;实验性节点,适配SDXL/SD1.X,不支持Flux。
💡 在ComfyUI中对负向提示施加负影响而不生成负样本。
🍴 5 Forks💻 Python🔄 2025-03-20
📦
网盘下载
复制链接后前往夸克网盘下载
https://pan.quark.cn/s/c73fe210bae7
image
image
00022UI_00001_
example workflow png
00023UI_00001_
00025UI_00001_
📄 README

Negative-attention-for-ComfyUI-

Takes the difference in between the positive and negative conditioning at the cross attention.

This is an experiment.

Only tested with SDXL and SD 1.X.

Will not work with Flux (see bottom note).

This allows to:

  • Get a negative influence without generating a negative prediction
  • Let the unconditional prediction be unconditional
  • Or doubling down by having the same done for the negative prediction (overblown results are to be expected unless using an anti-burn or low CFG scale)
  • In order to do this for now the negative conditioning is sneaked to the attention by being concatenated to the positive by using a special node.

    They are then split at the half before the cross attention.

    Like any model patcher, it is to be plugged right after the model loader:

    An example workflow is provided.

    Example:

    No modification:

    Difference in positive and negative conditionings:

    Difference in positive conditioning, negative conditioning empty:

    No modification using empty negative conditioning:

    Note

    I haven’t managed to make this work with anything but SDXL / SD1.5

    I did spend two hours looking for how to patch the equivalent of the cross attention for Flux but did not find how (like the keywords for the patch or something).

    Any help appreciated!