SMC Anchor-Guided Compand
Your detail crop drifted. This node drags it back to the stable version.
- high_image
- mask
- config
- anchor_image
- output
- anchor_image
- warped_high_image
- flow_visual
- debug_mask
- metrics
If you've detailed a face crop with FLUX.2 Klein and pasted it back only to find the eyes slightly bigger, the head slightly wider, the color a little flatter - you know exactly the problem this node exists for. SMC Anchor-Guided Compand (class SMCCompand) is the flagship node of xmarre's Stable Manifold Compander pack. It takes your high-resolution image, a mask, and an SMC_CONFIG, and pulls the result back toward a lower-resolution "anchor" version that's usually compositionally more stable.
The name is a bit of a mouthful, but the idea is simple: a model that's happy generating at 1MP starts to drift when you push it to 2-4MP or through a detail-crop pass - content spreads outward, low-frequency tone washes out, chroma flattens. The anchor is a small version of the same image that didn't have time to drift. Compand compares the big result to the small reference and corrects the big one toward it, without touching the fine detail.
How it works
The pipeline inside SMCCompand is training-free and heuristic (the README is upfront that it's not an optical flow solver or learned warp):
- If you don't feed an
anchor_image, it derives one: downscale the input toconfig.anchor_mpmegapixels, then bicubic-upscale back to full size. - Split both anchor and high image into low/high frequency via Gaussian blur (
base_blur_radius, default 9). - Estimate an "expansion ratio" - how much broader/flatter the high-res gradient structure got inside the mask, measured by weighted second moments of gradient energy.
- Build a radial inward flow field scaled by
warp_strengthandradial_strength, capped bymax_inward_shift_px(default 6px) so it can never tear the image. - Warp the high image along that flow (
warped_high_image), then restore low-frequency color in Oklab: pull luminance mean toward the anchor, boost chroma/contrast where the flow says content diverged. - Re-add the high-frequency detail (
detail_preservation) and blend the corrected region back inside the mask edge (edge_softness), so pixels outside the mask are untouched.
The inputs that matter
high_image- the drifted high-res image or detail crop.mask- where the correction applies. Mask quality is half the result; a sloppy mask means a sloppy correction.config- theSMC_CONFIGobject built by the SMC Config node.anchor_image(optional) - bring your own low-res reference if you have one. Leave it empty and the node derives one fromanchor_mp.
The outputs
The main one is output - wire that to your Save/Preview. The rest are debug plumbing: anchor_image (the reference it used), warped_high_image (the warped intermediate), flow_visual (a color-wheel viz where hue = shift direction and brightness = shift magnitude), debug_mask, and metrics (a string with estimated_expansion_mean - above 1.0 means the high-res output spread out and got corrected).
Install
Install via ComfyUI Manager (search "Stable Manifold Compander") or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-StableManifoldCompander
# restart ComfyUI
No extra Python packages, no model downloads, no API keys - it's pure torch math on top of a normal ComfyUI install.
Troubleshooting
If the correction looks too weak, raise warp_strength and check that estimated_expansion_mean in metrics is actually above 1.0 - no drift measured means nothing to fix. If things start looking wobbly or "sucked in", lower warp_strength or max_inward_shift_px. Flat color after correction means chroma_restore needs to go up. And if the mask edge shows a seam, raise edge_softness. The classic trap: feeding a mask that covers half the background, which makes the anchor-matching pull the whole frame inward instead of just the subject.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| high_image | IMAGE | — | |
| mask | MASK | — | |
| config | SMC_CONFIG | — | |
| anchor_imageopt | IMAGE | — |
Outputs (6)
| Name | Type | Description |
|---|---|---|
| output | IMAGE | — |
| anchor_image | IMAGE | — |
| warped_high_image | IMAGE | — |
| flow_visual | IMAGE | — |
| debug_mask | MASK | — |
| metrics | STRING | — |