姿态重定向对齐
Your Pose Doesn't Fit the Frame? Align It Before ControlNet Sees It
- 参考姿态图
- 源姿态图
- 对齐后姿态图
- 对齐后遮罩
- 缩放倍率
- 横向偏移
- 纵向偏移
Ever exported a pose from one video and tried to drive another character with it, only to get a tiny skeleton floating in a corner? That's the failure mode this node kills. Pose ControlNets are absolute - a skeleton drawn at a small size stays small, and the model dutifully draws a small person wherever you pointed it. PoseRedirectAlignByHead rescales and repositions one pose image so its person lines up with the person in another pose image, before ControlNet ever sees it. One node, zero re-rendering.
It's the image-level half of the comfyui-pose-redirect-align pack (the other, PoseMetaRetargetAlign, does the same job on keypoint data instead). It's written by a Chinese-speaking author, so expect the node label "姿态重定向对齐" and the inputs to appear in Chinese in ComfyUI. Don't let that throw you - it's a small, honest utility.
How it works
Pure geometry, no AI involved. The code does exactly four things per pair:
- Finds the person. It samples the median color of the image's border strips, then treats any pixel that differs from that background by more than
背景阈值(background threshold) as foreground - with a little morphological closing/opening to tidy the blob. - Scales. It measures the foreground's bounding-box height in both images and scales the source so the heights match, clamped between
最小缩放and最大缩放. - Finds the head. In the top slice of each person's bounding box (the
头部搜索比例/ head search ratio band), it takes the centroid of the largest connected blob. That's the head anchor - the bit you care about when you're framing a person. - Translates. It shifts the scaled source so its head anchor lands on the reference's, then pastes it onto a canvas filled with the reference's background color.
Because it works on the rendered pixels, it doesn't care where your pose came from - DWPose, OpenPose, a drawn stick figure, a frame of a dancing video. And there's no model download, no GPU requirement, nothing to train. It runs in milliseconds on CPU.
The inputs that matter
- 参考姿态图 / 源姿态图 (both
IMAGE) - the reference is the framing you want, the source is the pose you want to transfer. Swap them and you swap the direction. - 背景阈值 (default 18) - if your pose image has a noisy or gradient background, raise it so only the person counts as foreground.
- 头部搜索比例 (default 0.22) - controls how tall the "head band" is. If the head anchor lands too high or too low, nudge this.
- 最小缩放 / 最大缩放 (defaults 0.25 / 4) - the clamp on how much the source can shrink or grow. If your two poses differ wildly in size, widen these; if the node "does nothing," the clamp is usually why.
Outputs: 对齐后姿态图 (the remapped pose IMAGE, wire this straight into a ControlNet Apply node), 对齐后遮罩 (a MASK of the aligned person - handy for preview or compositing), plus 缩放倍率 (FLOAT), 横向偏移 and 纵向偏移 (INTs) so you can see exactly what transform was applied. That scale output is your first debugging read: if it's pinned at the min or max, the clamp is doing your work for you.
Installing it
The whole pack is one small folder. Easiest route: ComfyUI Manager → search comfyui-pose-redirect-align → install → restart. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/playboy-dongan/comfyui-pose-redirect-align
# then restart ComfyUI
Dependencies are numpy, opencv-python, and torch - all three are already in your ComfyUI environment, and there are no model files to fetch. It's the rare custom node that installs in seconds and can't break anything. One gotcha from the README: if you run ComfyUI on a remote server, the node has to live on that machine - a pose-alignment node running locally while the render happens remotely is useless, and platforms that forbid custom nodes simply won't run it.
Troubleshooting
- Pose not detected / wrong blob → raise
背景阈值; the foreground detection is just a color-difference against the border, so a busy background defeats it. - Head anchor too high or too low → adjust
头部搜索比例. - Nothing seems to change → check the
缩放倍率output against最小缩放/最大缩放, and make sure both inputs aren't already identical framing. - Batch mismatch error → each input batch must be size 1 (broadcast) or match the other exactly.
Pose conditioning is one of the most reliable ControlNets on every base from SD 1.5 through the Flux-era unions, so it's worth getting the input right instead of wrestling the weight slider. This node is the missing resize step between "pose I found" and "pose I wanted."
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| 参考姿态图 | IMAGE | — | |
| 源姿态图 | IMAGE | — | |
| 背景阈值 | INT | 181–255 | 与边界背景差异足够大的像素会被视为 pose 前景。 |
| 头部搜索比例 | FLOAT | 0.220.05–0.45 | 用于估计头部锚点的上半部区域比例。 |
| 最小缩放 | FLOAT | 0.250.01–10 | — |
| 最大缩放 | FLOAT | 4.000.01–10 | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| 对齐后姿态图 | IMAGE | — |
| 对齐后遮罩 | MASK | — |
| 缩放倍率 | FLOAT | — |
| 横向偏移 | INT | — |
| 纵向偏移 | INT | — |