Nodes/ComfyUI Model Bending/Latent Operation (Custom)
ComfyUI Node

Latent Operation (Custom)

Latent Operation (Custom)

By abuzreq·Created about a year ago·Updated 3 months ago· 21
Latent Operation (Custom)
    • LATENT_OPERATION
    operation
    float_param0.00
    float_param20.00
    int_param5
    int_param25
    bool_paramfalse

    The pack's dedicated builder nodes cover add-scalar, multiply-scalar, rotate, and add-noise - but those are the highlights. This node is the backstage pass: it exposes all ~24 latent operations the pack actually implements, from add_noise and multiply_scalar to rotate_x/y/z, threshold, soft_threshold, inversion, clamp, gradient, sobel, and more. Pick one from the dropdown and it returns a LATENT_OPERATION, same type as the dedicated builders, ready for ConditioningApplyOperation, LatentApplyOperationCFGToStep, or Latent Operation To Module.

    This is the node the pack's own conditioning_bending.json workflow uses (set to add_noise at 0.1), and it's the honest answer to "I want to try everything this pack does to latents without building ten nodes." You get a dropdown plus five generic parameter slots - float_param, float_param2, int_param, int_param2, bool_param - and which ones matter depends on the operation you picked:

    • Integer-parameter ops (reflect, dilation, erosion) read int_param.
    • No-parameter ops (absolute, log, gradient, hadamard1) take nothing.
    • Boolean ops (sobel) read bool_param.
    • Dual-float ops (clamp, scale) read float_param and float_param2.
    • Everything else reads float_param.

    That mapping isn't documented in the UI, which is the classic friction point - you'll be setting float_param for most ops and wondering why sobel ignores it (it wants the boolean).

    The operations are the pack's internal library, mostly adapted from the GAN "network bending" work the whole project is inspired by. rotate_x/y/z rotate the latent in feature space (a rotation matrix applied across the channel dimension - not a spatial image rotation), while threshold zeroes any activation below the given magnitude. The variety is genuinely the point: soft_threshold and clamp are gentler siblings of threshold, and inversion flips sign of values, which reads as a kind of "opposite day" for that tensor.

    Install: ComfyUI Manager → search "ComfyUI-Model-Bending" → install → restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/abuzreq/ComfyUI-Model-Bending
    

    Dependencies: kornia and scikit-learn.

    Honest caveats: it's marked experimental, the dropdown list is long enough to be intimidating, and because the parameter mapping is implicit, expect a few "why is nothing happening" moments (usually a parameter being routed to the wrong slot). Start with add_noise / float_param 0.1, wire it into ConditioningApplyOperation per the included workflow, and you'll feel out the pattern fast. It's a lab-in-a-node for latent tinkering.

    Categorymodel_bending

    Inputs (6)

    NameTypeDefaultDescription
    operationCOMBO24 options: parse_step_str_to_ranges, add_full, add_sparse, add_noise, add_normal, multiply_scalar, +18
    float_paramoptFLOAT0.00
    float_param2optFLOAT0.00
    int_paramoptINT5
    int_param2optINT5
    bool_paramoptBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    LATENT_OPERATIONLATENT_OPERATION