Flip Module (Bending)
Mirror a layer's activations and watch the image turn around
- BENDING_MODULE
If you've ever generated a portrait where the subject is facing the wrong way, you know the instinct: mirror it and move on. In a pixel editor that's one keystroke. In the middle of a diffusion model it's a different animal - you're not mirroring the output, you're mirroring the model's internal representation of the scene while it's still deciding, and the sampler then builds the rest of the image around that mirrored half-finished world.
Flip Module (Bending) is the one-input node that does it. It produces a BENDING_MODULE, which means on its own it does absolutely nothing - you have to hand it to something that knows where to apply it.
What it is
Every module node in this pack works the same way: it's a tiny object holding an operation, and it gets applied to a hooked layer's activations during sampling. Flip's operation is the simplest in the set - flip the last two axes of the tensor it receives.
horizontal(the default) mirrors left/right - the last axis.verticalmirrors top/bottom - the second-to-last.bothdoes both, which is a 180° rotation of the feature map.
On a 4-D image tensor (B, C, H, W) that's exactly what it sounds like. On a 5-D video tensor the non-temporal ops fold time into the batch first, so each frame is mirrored in place - the clip plays forwards, just flipped. (If you want the order of the frames reversed, that's a different node: Frame Reverse Module.)
There's no padding parameter and no interpolation, because mirroring is exact - it's an index permutation, so it can't produce NaN or out-of-range values. It's the safest module in the pack on that front.
Wiring it
The module goes into an applier:
- Model Bending - with a layer path from Bendable Layer Catalogue.
middle_block.*is the usual first stop on UNet models. - DiT Block Bending - with a block spec like
double:0-6, andspatialleft on so the tokens are laid out on the picture grid before flipping. - Attention Map Bending - flips the attention map's frame, which changes where each prompt token lands without changing the prompt.
- Model VAE Bending - flips the VAE's feature maps, which is a rougher, more texture-level version of the same trick.
All of them take the module as an input socket, so one Flip node can fan out to several appliers if you want to mirror at two places at once.
What it looks like
Flipping a whole model's activations at the middle block produces an image that is recognisably the same scene with its left-right sense inverted: asymmetries swap sides, text inside the image reverses, one-sided lighting moves to the other cheek. Flip a few mid blocks and late blocks only, and you get asymmetry weirdness - a face that reads as subtly wrong without looking mirrored, because different parts of the network disagree about which way the subject is facing.
That second one is the interesting use. Complete mirrors are something a pixel editor does better. Partial, layer-specific mirrors do something a pixel editor can't.
Inputs and output
One input - direction, horizontal / vertical / both - and one output, BENDING_MODULE. That's the entire node.
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
kornia and scikit-learn are the pack's only dependencies; flip itself doesn't need kornia, but the pack's geometry modules mean the import is mandatory. Restart ComfyUI after install. Diagnostics appear in the console prefixed [model-bending].
Where people get burned
- Forgetting
spatial. On DiT Block Bending withspatialoff, the tokens are a flat list with no width or height, so a "flip" rearranges token order rather than mirroring a picture. Leave it on unless you know why you're turning it off. - Bending a container path. Bendable Layer Catalogue will tell you when a path resolves to a container's last child; the flip happens there, which may be one level shallower than you assumed.
- Stacking flips until the effect cancels. Two horizontal flips on the same layer is a no-op that costs you nothing but confusion. Bends on the same layer apply last-to-first, which is worth remembering when you're stacking modules.
- Expecting perfect left-right symmetry in the output. You mirrored the representations; the sampler still has its own opinions about what belongs on the left. That's the feature, not a bug.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| direction | COMBO | horizontal | 3 options: horizontal, vertical, both |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| BENDING_MODULE | BENDING_MODULE | — |