Nodes/ComfyUI Model Bending/Gradient Module (Bending)
ComfyUI Node

Gradient Module (Bending)

Make a layer see nothing but edges

By abuzreq·Created about a year ago·Updated 3 months ago· 21
Gradient Module (Bending)
    • BENDING_MODULE
    kernel_size3

    Morphological gradient is the difference between dilation and erosion - mathematically, it highlights the edges of features and discards flat regions. Apply it to a layer's activations and you're telling that layer to only "talk about" boundaries: everything interior flattens, and the signal becomes edges and transitions. In the Model Bending pack this is the sharpest, most graphic of the kornia-based modules - it strips a layer down to its outline.

    It produces a BENDING_MODULE, like all the module builders here, and gets injected into a model with Model Bending, Model Bending (SD Layers), or Model VAE Bending. Mechanically it's kornia.morphology.gradient with a square kernel of ones - the same kornia family as the pack's erosion and dilation modules (gradient is literally dilation − erosion), which is exactly why kornia is in the pack's requirements.

    One input, kernel_size, default 3, range 1–10 - the window of the morphological difference, i.e. how thick the edges come out. At 3 you get crisp, thin edge emphasis; crank it toward 10 and the "edges" get fat and smeary, turning a layer's output into chunky line art. This is the module you reach for when you want a layer's structure to read as drawing - edges, silhouettes, boundaries - rather than shading or texture.

    Where it gets interesting is placement. On an early UNet layer, gradient-bending produces results that lean hard toward line-art and illustration - the model's texture pipeline never gets the smooth response it expects, so images come out flatter and more graphic. On a middle-block layer it distorts composition in wilder ways, since the "edges" it's emphasizing are the model's internal abstractions, not literal image edges. It's also a genuinely informative ablation: bend a layer to pure edges and you can see exactly what shape of information it contributes to the final image.

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

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

    kornia is required and Manager installs it; on a manual clone, pip install -r requirements.txt.

    The honest warning: gradient at high kernel sizes eats everything that isn't an edge, so don't be shocked when a portrait comes back looking like an etching of a person made of borders. That's the node doing its job - it's the most aggressive way in the pack to flatten a layer's output into pure structure, and half the fun is discovering which layers survive it.

    Categorymodel_bending

    Inputs (1)

    NameTypeDefaultDescription
    kernel_sizeINT31–10

    Outputs (1)

    NameTypeDescription
    BENDING_MODULEBENDING_MODULE