Nodes/ComfyUI-ZML-Image/ZML_相等判断
ComfyUI Node

ZML_相等判断

Count how many of your four inputs equal the reference — and pass it through

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_相等判断
  • 目标A
  • 比较对象B
  • 比较对象C
  • 比较对象D
  • 比较对象E
  • 相等数量
  • 任意输出

ZML_相等判断 is a tiny logic node with an oddly specific job: you give it a reference value and up to four things to compare, and it outputs the count of matches - plus the reference itself, passed through. It's the graph-language way of asking "how many of my four candidates agree with the target?" in one node, from the pack's logic family.

The source is exactly as described in the author's docstring: "set target A, compare BCDE to A, every one equal to A adds one, output an integer." The interesting part is the type handling. It declares any_type sockets, so it accepts anything, and it's tensor-aware - if both sides are torch tensors it uses torch.equal, which checks shape and values, so it's a real equality test on images and latents, not just numbers and strings. Everything else falls back to plain ==. Comparisons that throw (like str == tensor in some cases) count as unequal instead of crashing, which is a nicer failure mode than a stack trace.

The interface

  • 目标A - required, any type. The reference.
  • 比较对象B / C / D / E - optional, any type. Leave unwired inputs just don't count.
  • Outputs: 相等数量 (INT, 0–4) and 任意输出 (any type - A, passed through).

What it's actually for

Two natural jobs. One: a decision signal - "are all four of my candidate images identical to the reference?" feed the count into a switch or boolean logic and gate downstream work on 相等数量 == 4. Two: a pass-through with a built-in check, since you get A back on the second output anyway - the count rides along while the data keeps flowing, which is exactly the "one wire, several consumers" style the plumbing layer is built around. The pack's README mentions it was added alongside the switch and toggle nodes as part of a logic toolkit for exactly this kind of branching.

The honest limits: it's four comparisons, hard-coded, and it's equality only - no greater/less-than, no threshold. If you need >= or fuzzy matching you're in the wrong node, and a "relative comparison" that only knows == is a bit of a misnomer. But for its one job - count matches against a reference - it's clean and complete, and the any-type sockets make it far more flexible than its niche name suggests.

Install

Part of ComfyUI-ZML-Image. ComfyUI Manager → search ComfyUI-ZML-Image, or:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image

restart. No models, no dependencies beyond the base stack, zero GPU cost. Chinese-first UI, so the README's translation patch helps English users find the inputs. One-person, 160+-node pack: if a comparison behaves oddly with an exotic type, the GitHub issues page is the support channel.

Categoryimage/ZML_图像/逻辑

Inputs (5)

NameTypeDefaultDescription
目标A*
比较对象Bopt*
比较对象Copt*
比较对象Dopt*
比较对象Eopt*

Outputs (2)

NameTypeDescription
相等数量INT
任意输出*