ComfyUI Node

凤希AI - 比较

How a ComfyUI graph makes a decision

By fxai666·Created 7 months ago·Updated about 23 hours ago· 46
凤希AI - 比较
  • a
  • b
  • boolean
◄comparisona == b►

Why a comparison node exists at all

ComfyUI is a dataflow graph, not a program: there are no if statements, no branches in the normal sense. Every "if" you see in a workflow is really an if that's been pushed into a node - usually a switch that takes a boolean. So the boolean has to come from somewhere, and that somewhere is a comparison.

FxAiCompare (凤希AI - 比较) is that source. Two values in, one boolean out. It's the least glamorous node in this pack and the one you end up using constantly: stop the loop when index >= segments, save the image only when frame_count > 0, switch to the high-res branch when width > 1024.

How it works

It's a lookup table of ten lambdas keyed by the comparison value; the node just picks one and calls it.

"a == b"   "a != b"   "a < b"   "a > b"   "a <= b"   "a >= b"
"a > 0"    "a <= 0"   "b > 0"   "b <= 0"

The last four are the useful hack: they only look at one operand, so you can leave the other socket empty. a > 0 is your standard "is this thing non-empty / did we get any frames" test, and the author says as much in the tooltip - the other input doesn't need connecting. That's how you get a truthiness check without a dedicated node.

Both a and b are wildcard sockets, so the comparison works on ints, floats, strings, even booleans. Feed it a STRING and a == b becomes a string equality check, which is handy for "did the LoRA name change".

Inputs and outputs

| Socket | What it is | | --- | --- | | a | wildcard, first operand | | b | wildcard, second operand (ignored by the four one-sided modes) | | comparison | the ten-choice dropdown, defaults to a == b | | boolean (output) | BOOLEAN, type BOOLEAN |

The single output is boolean, and it wires into anything that accepts BOOLEAN: FxAiIfElse to route two branches, the condition input of FxAiWhileLoopStart / FxAiWhileLoopEnd to control a loop, or any core node with a boolean widget converted to an input.

How you'd actually use it

The canonical pattern in this pack is a condition loop: FxAiWhileLoopStart → process a segment → FxAiCompare on the segment index vs. the total → FxAiWhileLoopEnd. The compare node is the "are we done yet" sense organ. Same shape for a counted loop where you drive the exit yourself, or for a guard that decides whether a face-refine stage runs at all.

Outside loops, it's the glue behind A/B routing: compare a width to 1024, send the boolean into FxAiIfElse, and now your upscale path differs for portrait vs. landscape inputs without you duplicating the graph.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/fxai666/fxai-toolkit

Restart, or install through ComfyUI Manager by searching fxai-toolkit. The pack pulls in soundfile and psutil automatically at import; this node needs neither, and needs no model files. Zero-dependency logic, which is why these nodes load on any ComfyUI build recent enough to run the pack at all.

Where it bites

Type mismatches throw, they don't coerce. The comparison is plain Python: "1280" < 1024 raises a TypeError and takes the node down mid-run. If you're comparing something that came out of a string node against an int, that's the bug - put a parser between them (FxAiSimpleMath will do it by accident, since it casts).

Empty optional inputs aren't "zero". An unwired wildcard comes through as None, so a == b with nothing on b compares against None rather than 0. On the one-sided modes this doesn't matter, which is exactly why they exist.

It's not a gate. The node compares; it doesn't stop anything. If you want the branch not to execute (rather than to execute and be discarded), the boolean goes to FxAiIfElse, whose unselected side is lazy and never evaluated. Half of "my workflow still runs the expensive path" complaints are someone wiring a compare output into a bypass instead of a lazy switch.

Node absent from the menu. This pack registers each node in its own try/except and prints ❌[凤希AI] 节点加载失败 on the console, so a failed import removes a node quietly. Console first, then restart.

Category凤希AI/逻辑

Inputs (3)

NameTypeDefaultDescription
a*—
b*—
comparisonCOMBOa == b后四项只看一个操作数(`a > 0` 这类),另一个接不接都行。

Outputs (1)

NameTypeDescription
booleanBOOLEAN—