Nodes/ComfyUI-Prediction/Avoid and Erase Prediction
ComfyUI Node

Avoid and Erase Prediction

Keep the negative prompt from dragging your image sideways

By redhottensors·Created 3 years ago·Updated 2 years ago· 15
Avoid and Erase Prediction
  • positive
  • negative
  • empty
  • guidance
erase_scale0.20

Your negative prompt has a dirty secret: it doesn't just push the image away from what you named. It pushes sideways. Avoid and Erase is this pack's fix - a "v2" of the Perp-Neg idea that produces a pure guidance vector instead of a finished prediction. That last part trips up everyone on first use, so we'll get to it.

What it does

Like the rest of ComfyUI-Prediction, this node is a predictor: a building block in a graph that tells the pack's sampler how to denoise each step. It takes three predictions - positive, negative, and empty - plus one knob, erase_scale, and outputs something the pack names guidance. Not prediction. The naming is the whole story.

The math is a modified Perp-Neg. With pos_ind = positive - empty and neg_ind = negative - empty, the output is:

oproj(pos_ind, neg_ind) - oproj(neg_ind, pos_ind) * erase_scale

Where oproj is vector rejection - the part of one vector perpendicular to another. Read it out loud: keep the component of the positive that the negative can't pull off-course, then subtract a scaled chunk of the component of the negative that points away from the positive. The README's one-liner is cleaner than my paraphrase: it "avoids moving in the direction of the negative guidance." At erase_scale 0 you get pure "avoid"; crank it toward 1 and you actively scrub the leftover negative direction too. The default is 0.2, and it's a reasonable place to start.

The gotcha that gets everyone

Most predictors in this pack - CFG Prediction, Perp-Neg, the combiners - output a complete noise prediction you can feed straight to the sampler. Avoid and Erase does not. Its output is a guidance vector, a direction in latent space, and you still have to add it back to your empty prediction before it's usable. The README spells out the two ways: recombine it with the Scaled Guidance Prediction node (guidance in, empty prediction as baseline), or add it via a Combine Predictions node, readying it for Characteristic Guidance Prediction. Plug the guidance output straight into Sample Predictions and you'll get garbage - the type is PREDICTION so ComfyUI won't even warn you loudly.

Why you'd bother

Perp-Neg (also in this pack) is the established fix for the negative prompt's drift problem, dating to the 2023 paper that proved out the trick. Avoid and Erase is the refinement: it avoids heading along the negative at all rather than just stripping the perpendicular part. If you've ever watched a strong negative prompt subtly warp composition, tint colors, or nudge anatomy, this is the node to try. The trade-off is that it's a heavier graph - three prediction branches plus the recombination - and it's firmly aimed at the SD 1.5/SDXL lineage where real negative prompting still lives. On a guidance-distilled model running CFG 1, negatives do nothing, and no amount of erase will resurrect them.

Installing it

This node ships in the ComfyUI-Prediction pack by @RedHotTensors (Project RedRocket). Easiest route is ComfyUI Manager - search "ComfyUI-Prediction" and install. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/redhottensors/ComfyUI-Prediction

Then restart ComfyUI. No requirements.txt, no pip installs, no model files - it's pure Python wrapping ComfyUI's own sampler internals. Nodes appear under Add Node > sampling > prediction.

Common issues

  • Wiring guidance straight into the sampler. Remember: recombine with empty first.
  • Forgetting the pack's setup. You still need a Sample Predictions node as your sampler, a sampler from KSamplerSelect, and sigmas from a scheduler like BasicScheduler. Avoid and Erase just supplies part of the denoise.
  • ControlNet won't work with any of this pack - it's an explicit limitation, not your wiring.
Categorysampling/prediction

Inputs (4)

NameTypeDefaultDescription
positivePREDICTION
negativePREDICTION
emptyPREDICTION
erase_scaleFLOAT0.200–1

Outputs (1)

NameTypeDescription
guidancePREDICTION