ComfyUI Node Runs on cloud

Evaluate Integers

Evaluate Integers

By jags111·Created 3 years ago·Updated 4 months ago· 1,485
Evaluate Integers
    • INT
    • FLOAT
    • STRING
    python_expression((a + b) - c) / 2
    print_to_console
    a0
    b0
    c0

    Evaluate Integers lets you do actual math on your workflow's numbers. You type a small Python expression, feed in up to three values, and it computes the result - so instead of hardcoding "1536" somewhere, you can compute it from your base width times an upscale factor, or derive a step count from another number. It's a calculator node for people who got tired of doing arithmetic in their head every time they changed a resolution.

    It's part of the pack's SimpleEval trio (Integers, Floats, Strings), all built on the tiny simpleeval library that safely evaluates simple expressions.

    How it works

    The node exposes three optional integer inputs named a, b, and c, and a text field where you write an expression using them. The default expression is ((a + b) - c) / 2, which mostly exists to show you the shape of the thing. Whatever the expression evaluates to comes out three ways at once, so you can wire the result wherever it fits.

    Because it evaluates real Python expressions, you get the normal operators and functions simpleeval allows - arithmetic, comparisons, the usual math. You're not limited to the default template; replace it with whatever you need.

    The inputs and outputs

    • python_expression - the formula, as text. Reference the inputs by their letters (a, b, c).
    • a / b / c - up to three integer inputs. They're optional, so you can hardcode numbers in the expression and skip the wires, or feed values in from elsewhere in the graph.
    • print_to_console - True/False; echoes the result to the console, which is handy when you're debugging why a computed value came out weird.

    The outputs cover three types - INT, FLOAT, and STRING - so the same result is available however the downstream node wants it. That's deliberate: division might give you a float, but a width input wants an int, and this way you just grab the right socket.

    Installing it

    ComfyUI Manager → search Efficiency Nodes for ComfyUI, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jags111/efficiency-nodes-comfyui
    

    Restart after. One extra step for the eval nodes specifically: they need the simpleeval Python library. If it's not already present, install it into ComfyUI's Python environment with pip install simpleeval and restart. Without it, the Evaluate nodes won't function even though the rest of the pack loads.

    Common issues

    If the eval nodes are missing or dead while the rest of the pack works, the culprit is almost always a missing simpleeval - install it into the same Python environment ComfyUI runs on (portable and venv installs trip people up here).

    Expression errors are the other one: a typo, referencing a letter you didn't feed, or an operation simpleeval doesn't allow will fail the node. Turn on print_to_console to see what it's actually computing. And remember integer division - if you need a clean whole number for a width or step count, take the INT output and mind the rounding.

    Pack-wide: an IMPORT FAILED at startup (often a pip freeze error) means the whole pack didn't load - update ComfyUI, packages and the node.

    CategoryEfficiency Nodes/Simple Eval

    Inputs (5)

    NameTypeDefaultDescription
    python_expressionSTRING((a + b) - c) / 2
    print_to_consoleCOMBO2 options: False, True
    aoptINT0-48000–48000
    boptINT0-48000–48000
    coptINT0-48000–48000

    Outputs (3)

    NameTypeDescription
    INTINT
    FLOATFLOAT
    STRINGSTRING