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

Translate Module (Bending)

Shift a layer sideways and the whole subject moves

By abuzreq·Created 2 years ago·Updated 11 days ago· 26
Translate Module (Bending)
    • BENDING_MODULE
    ◄dx0.00►
    ◄dy0.00►
    ◄paddingborder►

    "Move the subject to the left" is a thing diffusion models are famously bad at. You reword the prompt, you add "on the left side of the frame", you get the same centred portrait with a slightly different background. Prompting is a blunt instrument for spatial instruction.

    Translate Module (Bending) does the direct version: shift the activations of a layer by a fraction of the frame, and let the sampler rebuild the image around the moved features. On an attention map it literally moves where a prompt token lands. It's one of the cleanest "wait, that actually works" nodes in the pack, and it needs an applier to do anything at all.

    How it does it

    This is the geometry-op part of the pack, and it's kornia underneath - a batched affine warp, with the fractional shift converted into cell offsets before it's applied. The input tensor is moved by (dx * width, dy * height) in cells of the incoming feature map, with the padding mode deciding what fills the area that vacates:

    • zeros - empty space becomes 0. Reads as a hole if the layer's activations are signed, but at low magnitudes it's usually just a darker/emptier band.
    • border - the nearest edge value is repeated. The default, and the one that smears least obviously.
    • reflection - a mirror of the edge. Sometimes gives a plausible continuation, sometimes gives you a duplicated limb.

    The shift is in fractions, so dx: 0.5 moves content half a frame whether you're on a 64×64 latent or a 128×128 one, and whether the layer runs at 1× or 1/8 resolution. That resolution independence is the reason the interface is fractions rather than cells - and yes, the sharp-eyed will notice it's the opposite convention from the blur's sigma, which is in cells. Read the tooltips; they're explicit.

    Positive dx is right, positive dy is down. The whole effect composes with the model's own training: shift the mid-block features of a portrait and you don't usually get a translated portrait, you get a portrait that has reconsidered where the subject goes, background adapting along with it. Asymmetries in the frame are what make it look intentional rather than broken.

    Inputs and output

    • dx - horizontal shift, default 0, range −1 to 1, step 0.01.
    • dy - vertical shift, default 0, range −1 to 1, step 0.01.
    • padding - border (default), zeros, or reflection.

    Output: BENDING_MODULE.

    Wiring it

    The best known use for this module isn't a layer path at all - it's the attention-map route. Put Translate into Attention Map Bending, target a specific word in tokens (with clip and prompt wired so the node can find it), and the word's attention lands where you shifted it. Frame-level off-centre compositions stop being a prompt problem. The README's advice for attention bending applies here too: keep the magnitude small, target a few blocks, and start in the early steps where layout is still being decided.

    Otherwise: Model Bending with a path, or DiT Block Bending with spatial: true (leave spatial on, or you'll be shifting a token list and the result won't be a spatial shift at all).

    Combine it with Timestep Gated Bending if you want the shift to happen while composition forms (t 1 → 0.7) and then be frozen in place, rather than being re-applied at every step and pulling the image further and further off-centre.

    Install

    ComfyUI Manager → search "ComfyUI Model Bending", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/abuzreq/ComfyUI-Model-Bending
    pip install -r ComfyUI-Model-Bending/requirements.txt
    

    Rotate, Scale and Translate are the modules that genuinely need kornia, which is one of the pack's two dependencies (scikit-learn is the other, for the PCA/HSpace nodes). If kornia fails to install, the entire pack fails to load and none of its nodes appear in the menu - not just these. Restart ComfyUI after installing, and look for [model-bending] lines in the console.

    Where people get burned

    • Big dx/dy applied at every step. Each step re-shifts what's already shifted, so a 0.2 shift can walk the subject clean off the canvas over 20 steps. Gate it, or keep it small, or both.
    • Padding surprises. zeros can introduce a hard edge that the sampler then interprets as a real object boundary. border stretches texture, which is usually the least distracting. reflection occasionally produces a mirrored duplicate of a limb - which some people want.
    • Turning spatial off. On token tensors there is no meaningful left or right, so the shift becomes a reshuffle. This is the single most common way to make the node appear to do nothing.
    • Expecting a crop. This is not an outpaint tool and it doesn't extend the canvas. It moves internal features; the frame stays the same size.
    • Assuming the frame shifts uniformly. Shift a couple of middle blocks and the model will keep parts of the image where they were. That partial, argumentative shift is often more interesting than a uniform one - but it isn't what "move it left" sounds like.
    Categorymodel_bending

    Inputs (3)

    NameTypeDefaultDescription
    dxFLOAT0.00-1–1Horizontal shift as a fraction of the width (positive = right)
    dyFLOAT0.00-1–1Vertical shift as a fraction of the height (positive = down)
    paddingCOMBOborderHow areas moved in from outside the frame are filled: zeros, the nearest edge value, or a mirror

    Outputs (1)

    NameTypeDescription
    BENDING_MODULEBENDING_MODULE—