Nodes/ComfyUI-Portrait-Maker/RatioMerge2Image PM
ComfyUI Node

RatioMerge2Image PM

The one-dial image blender — RatioMerge2Image PM

By THtianhao·Created 3 years ago·Updated 2 years ago· 201
RatioMerge2Image PM
  • image1
  • image2
  • IMAGE
fusion_rate0.5

Half the art of a believable face-swap or portrait edit is knowing when to stop. Blend the generated face in at 100% and it can look alien; dial it back and it reads as the real person. RatioMerge2Image PM is the dial - it takes two images and mixes them by a single number, and in the ComfyUI-Portrait-Maker workflow that's exactly what it's for: blending the freshly generated face back toward the original photo until you land on the likeness/sameness sweet spot.

It's one of the pack's utility nodes (this pack is a node-by-node port of Alibaba's EasyPhoto pipeline), sitting alongside sibling merges like MaskMerge2Image. The difference matters: RatioMerge blends the whole frame uniformly, while MaskMerge uses a mask so only one region transitions.

How it works

There's no model and no AI here - it's a per-pixel weighted average:

result = image1 * (1 - fusion_rate) + image2 * fusion_rate

One line, and that's the whole node. It's deterministic, instant, and embarrassingly useful.

The input that matters

  • image1 and image2 (IMAGE) - both same-resolution tensors.
  • fusion_rate (FLOAT, default 0.5, range 0–1) - the blend weight.

Now the trap, and it's a real one: the README says "higher values favor image1," but the code does the opposite. At fusion_rate = 0 you get pure image1; at 1 you get pure image2, and the curve is linear between. I've been burned by trusting docs over code before - trust the preview. If you want "mostly image1, a hint of image2," set it around 0.1–0.2.

Output and wiring

Output is a single IMAGE. In the EasyPhoto workflow it's used twice: once to blend the generated face with the original to soften the swap, and once near the end to mix the final composite back toward the source photo for a natural look. You can also abuse it as a quick opacity crossfade between any two frames, which is perfectly fine - it doesn't know or care what the images are.

Constraints worth knowing

Both inputs must be the same resolution, because the two tensors are added directly. Feed it a 512×512 and a 768×768 and you get a broadcast error, not a helpful hint. Resize one side first with PM_ImageResizeTarget or ImageScaleShort from the same pack. It handles batched frames fine, so you can crossfade whole sequences with it, but each frame has to match.

Installing

ComfyUI Manager (search "ComfyUI-Portrait-Maker") or:

cd ComfyUI/custom_nodes
git clone https://github.com/THtianhao/ComfyUI-Portrait-Maker.git

then restart. Fair warning: the pack's first launch downloads the full EasyPhoto model set with no hash check, and requirements.txt pulls in modelscope, tensorflow, insightface, and a diffusers pinned to 0.18.2. You don't need any of that for this node, but you get it anyway.

Common issues

Realistically, the only failure mode here is mismatched image sizes or forgetting which end of fusion_rate is which. If your blend looks like a double exposure, one image is probably half-transparent already (premultiplied alpha) or you're blending at 0.5 when you meant 0.1. Nothing else in this node can go wrong, which is precisely why it's the one you reach for.

Categoryprotrait/other

Inputs (3)

NameTypeDefaultDescription
image1IMAGE
image2IMAGE
fusion_rateFLOAT0.50–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE