Nodes/Self-Guidance nodes/CLIPConditioning
ComfyUI Node

CLIPConditioning

CLIPConditioning is the front end for self-guidance

By forever22777·Created 2 years ago·Updated about a year ago· 10
CLIPConditioning
  • clip
  • prompt
  • target_object
  • fix_object
prompt
target_object
fix_object

This node does nothing visual. No image comes out of it, and on its own it's the most boring thing in the pack. But the SelfGuidanceSampler refuses to do its trick without it, because the sampler needs to know which tokens in your prompt point at the object you're resizing - and finding those token positions is CLIPConditioning's entire job.

You get four inputs: prompt, target_object, fix_object, and clip. You get three CONDITIONING outputs: prompt, target_object, fix_object. In the pack's shipped example the setup reads: prompt "a photo of an eclair and a shot of coffee", target "eclair", fix "coffee". That's the whole workflow boiled down - one prompt, one object to change, one object to hold still.

How it works. It encodes the full prompt through the CLIP model into standard positive conditioning (that's the prompt output - the same thing a CLIPTextEncode would give you). Then it hunts through the tokenized prompt for the text in target_object and fix_object, using fuzzy string matching (fuzzywuzzy, scoring ≥90) to locate the right token positions, and exports those token-index lists as the target_object and fix_object CONDITIONING outputs. The sampler reads those to decide which cross-attention maps to watch and steer. Wire all three outputs into the matching inputs on SelfGuidanceSampler and you're done - there is no other wiring.

The traps:

  • The object name has to actually appear in the prompt. Fuzzy matching forgives near-misses, but if nothing scores ≥90 the node raises an ObjectError ("target_object or fix_object not in prompt"). "eclair" will not match a prompt that says "pastry."
  • Want to control multiple objects? Comma-separate them in the field: eclair, cake matches each independently.
  • This is CLIP tokenizing under the hood, so it's an SD1.5/SDXL-world node. Matching runs against the tokenizer's vocabulary, not against whatever LLM-encoder language a newer model uses - don't expect the same behavior on a 2026-era checkpoint.

Install. It ships in the same pack as everything else, so the install is the pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/forever22777/comfyui-self-guidance

or ComfyUI Manager → search "self-guidance," then restart. The only dependencies are diffusers==0.26.3 and fuzzywuzzy==0.18.0, both pinned. Feed its clip input from the pack's CheckpointLoaderMixWithDiffusers - though honestly any CLIP input works for the encoding; the node only needs the text encoder.

If you hit the "not in prompt" error, it's almost never this node's fault. It's a prompt that describes the thing without ever naming it.

Categoryconditioning

Inputs (4)

NameTypeDefaultDescription
promptSTRING
target_objectSTRING
fix_objectSTRING
clipCLIP

Outputs (3)

NameTypeDescription
promptCONDITIONING
target_objectCONDITIONING
fix_objectCONDITIONING