A ComfyUI custom node that provides model bending for diffusion models (e.g. Stable Diffusion, Flux). Model bending is the manipulation of the model activations at different chosen parts during sampling. Useful for creating experimential variations on an output or for testing out and understanding how models work. Manipulations include include addition, multiplication, noise, rotation, erosion, and dilation, and more. Inspired by network-bending of GAN models.
An example of rotating the outputs of the realisticvisionv51_v51vae model at its Unet's middle block (middle_block.2.out_layers), doing a full rotation (0-360deg).
Another loop where we inject a scalar value (-10 to 30) to the middle block (middle_block.2.out_layers) of the UNet of the sd_xl_turbo model.
This project provides:
- NEW Interactive Bending Web UI — Plug-and-play. Simply connect the model to the node then send the model downstream. Visualize the model structure (U-Net / transformer), pick layers, and apply bends from the browser. Copy bends as JSON and paste into the Apply Bends from JSON node. [Workflow]
- Model Bending (UNet) — Inject bending modules into your MODEL (UNet). Use Model Bending (custom paths) or Model Bending (SD Layers) (block + layer). The Model Inspector node helps you explore layers. [Workflow]
- NEW LoRA Bending — Replaces the Load LoRA node. Apply a bending module to LoRA weights. LoRA Bending bends every LoRA component (attached matrices) in the model. LoRA Bending (list) outputs the list of LoRA matrices in the model for you to pick from. [Workflow]
- VAE Bending — Inject bending modules into your VAE (Model VAE Bending). [Workflow]
- Conditionings × Operations — Apply operations to conditionings (CLIP encodings) to move them in semantic latent space (ConditioningApplyOperation). [Workflow]
- CFG step-wise operations — Apply operations to intermediate latents at a chosen denoising step (LatentApplyOperationCFGToStep). Latent operations (multiply, add, threshold, rotate, noise, custom) can be used with conditioning or sampling. [Workflow]
- Feature map visualization — Visualize Feature Map shows features at a given layer by averaging over channels into image-like tensors. Source [Workflow]
- Install ComfyUI.
- (Optional) Install ComfyUI-Manager and install this extension from the manager; or clone manually (see below).
- Restart ComfyUI.
- Web UI: open
{ComfyUI_URL}/web_bend_demo/. All bending nodes are under model_bending / model_bending_demo in the node menu.
- Clone into ComfyUI custom nodes:
Replace
cd ComfyUI/custom_nodes git clone <repository-url> ComfyUI-Web-Bend-Demo
<repository-url>with the actual repo URL (e.g. your fork or upstream). - Restart ComfyUI. The web UI is served at
{ComfyUI_URL}/web_bend_demo/.
| Path | Description |
|---|---|
| web/ | Web UI (explorer, config, assets). See web/README.md for setup and ViewComfy/local Comfy options. |
| scripts/ | Experiment runners, export, metrics, and explorer. See scripts/README.md. |
| nodes.py | ComfyUI nodes (e.g. InteractiveBendingWebUI, ApplyBendsFromJSON). |
| model_bending_nodes.py | Standalone bending nodes (inspector, VAE bending, latent/conditioning ops). |
| bendutils.py | Bending and graph utilities. |
- Local ComfyUI: Default
config.jspoints tohttp://127.0.0.1:8188; ensure ComfyUI is running with--listen. - Remote ViewComfy: To use remote inference, set
VIEWCOMFY_API_URL,VIEWCOMFY_CLIENT_ID, andVIEWCOMFY_CLIENT_SECRETinweb/js/config.js. The repository ships with empty values; do not commit real credentials.
| Node name | Category / use |
|---|---|
| Interactive Bending WebUI | Web UI — connect MODEL, configure bends in browser |
| Apply Bends from JSON | Paste JSON from web UI “Copy Bends” |
| Model Bending | UNet — inject at custom paths |
| Model Bending (SD Layers) | UNet — pick block + layer index |
| Model VAE Bending | VAE |
| Model Inspector | Inspect MODEL structure |
| Model VAE Inspector | Inspect VAE structure |
| Apply To Subset (Bending) | Apply module to random subset (batch/channel/spatial) |
| Add Noise / Add Scalar / Multiply Scalar / Threshold / Rotate / Scale / Erosion / Gradient / Dilation / Sobel Module (Bending) | Bending modules for MODEL or VAE |
| LoRA Bending | Load LoRA by name; bend all its components with a bending module |
| LoRA Bending (list) | Load LoRA by name; bend one component (by index or by key). Outputs: bent key, full key list |
| Visualize Feature Map | Feature map at a layer path |
| LatentApplyOperationCFGToStep | Apply operation at one denoising step |
| Latent Operation (Multiply Scalar, Add Scalar, Threshold, Rotate, Add Noise, Custom) | LATENT / CONDITIONING ops |
| ConditioningApplyOperation | CONDITIONING ops |
This is an ongoing project. Issues and feature requests are welcome (e.g. via GitHub issues as applicable).
In theory, most of the nodes should work with any model because bending only needs an address/path in the model and that can vary from one model to another. However the Interactive Bending node is currently supported and tested out for Stable Diffusion and Flux variants.
See web/LICENSE for license information.


