{"id":29296894,"url":"https://github.com/extraltodeus/negative-attention-for-comfyui-","last_synced_at":"2025-07-06T16:06:55.596Z","repository":{"id":275864516,"uuid":"927439074","full_name":"Extraltodeus/Negative-attention-for-ComfyUI-","owner":"Extraltodeus","description":"Takes the difference in between the positive and negative conditioning at the attention.","archived":false,"fork":false,"pushed_at":"2025-03-20T15:10:24.000Z","size":4269,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-20T16:25:45.523Z","etag":null,"topics":["comfyui","comfyui-nodes"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Extraltodeus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-05T00:33:33.000Z","updated_at":"2025-03-20T15:10:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5cdc23a-410c-49c8-8914-4b2d7738bdc7","html_url":"https://github.com/Extraltodeus/Negative-attention-for-ComfyUI-","commit_stats":null,"previous_names":["extraltodeus/negative-attention-for-comfyui-"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Extraltodeus/Negative-attention-for-ComfyUI-","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2FNegative-attention-for-ComfyUI-","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2FNegative-attention-for-ComfyUI-/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2FNegative-attention-for-ComfyUI-/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2FNegative-attention-for-ComfyUI-/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Extraltodeus","download_url":"https://codeload.github.com/Extraltodeus/Negative-attention-for-ComfyUI-/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extraltodeus%2FNegative-attention-for-ComfyUI-/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263932018,"owners_count":23531709,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["comfyui","comfyui-nodes"],"created_at":"2025-07-06T16:06:54.938Z","updated_at":"2025-07-06T16:06:55.586Z","avatar_url":"https://github.com/Extraltodeus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Negative-attention-for-ComfyUI-\nTakes the difference in between the positive and negative conditioning at the cross attention.\n\nThis is an experiment.\n\nOnly tested with SDXL and SD 1.X.\n\nWill not work with Flux (see bottom note).\n\nThis allows to:\n\n- Get a negative influence without generating a negative prediction\n- Let the unconditional prediction be unconditional\n- 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)\n\nIn 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.\n\n![image](https://github.com/user-attachments/assets/c43caf96-8f43-4c1c-8813-9a70a646f3cd)\n\nThey are then split at the half before the cross attention.\n\nLike any model patcher, it is to be plugged right after the model loader:\n\n![image](https://github.com/user-attachments/assets/a27d9796-e563-4661-985e-4ee53c37ebb0)\n\nAn example workflow is provided.\n\n## Example:\n\nNo modification:\n\n![00022UI_00001_](https://github.com/user-attachments/assets/537999fd-a594-4eb9-ad60-28c4958172ea)\n\nDifference in positive and negative conditionings:\n\n![example workflow png](https://github.com/user-attachments/assets/471f2b3f-53be-41aa-a940-5ee3eacb57d5)\n\nDifference in positive conditioning, negative conditioning empty:\n\n![00023UI_00001_](https://github.com/user-attachments/assets/af14ad61-8640-42b8-82ef-143dded04f10)\n\nNo modification using empty negative conditioning:\n\n![00025UI_00001_](https://github.com/user-attachments/assets/729bdeed-2dfe-4c87-923a-aa0eb5294e45)\n\n\n\n## Note\n\nI haven't managed to make this work with anything but SDXL / SD1.5\n\nI 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).\n\nAny help appreciated!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextraltodeus%2Fnegative-attention-for-comfyui-","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextraltodeus%2Fnegative-attention-for-comfyui-","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextraltodeus%2Fnegative-attention-for-comfyui-/lists"}