Nodes/Region Edit Toolkit/图像分区 · 眼内材质恢复
ComfyUI Node

图像分区 · 眼内材质恢复

Put the original irises back into the AI's eyes, without a pasted-eye look

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 眼内材质恢复
  • source_local
  • generated_local
  • local_generation_mask
  • source_landmarks
  • generated_landmarks
  • restored_local
  • iris_restore_alpha
  • preview
  • report_json
source_face_index0
generated_face_index0
crop_x
crop_y
iris_scale1.00
feather_pixels3.0
source_eye_material_restore_contract_versionface-local-source-gaze-aligned-iris-material-v3

Here's a face-edit failure you've definitely seen: the regenerated face looks fine, but the eyes are wrong - wrong iris color, wrong catchlights, gaze pointing somewhere else, pupils that look like featureless black discs. It's the single most common giveaway that a face was AI-edited, and it's why this pack has an entire node dedicated to the problem. RegionEditFaceEyeMaterialRestore surgically takes the source photo's iris material - the colored part, the pupil, the catchlights - and places it back inside the generated eyes, while leaving everything around the eyes (eyelids, lashes, brows, under-eye structure) as the AI generated it.

The clever bit is how it handles the placement problem. You can't just paste the source iris at the same pixel coordinates, because the generated face has different eye geometry and the model will have drawn the gaze somewhere else. So the node measures the source iris's position in an eye-local frame defined by the source eye corners and aperture, then maps that into the corresponding frame in the generated eye. The gaze direction is preserved from the source, which is the whole point of an identity-preserving edit.

How it works

You feed it both aligned crops (source_local and generated_local), the generation mask, landmark sets for both (source_landmarks, generated_landmarks from your MediaPipe-style face detection), and the crop coordinates (crop_x, crop_y) so it can place everything correctly. It picks which face in each landmark set via source_face_index / generated_face_index (default 0). Then:

  • It finds the iris region in the source eye frame.
  • It maps that region into the generated eye frame.
  • It pastes the source iris material in with a soft feather_pixels edge (default 3) and an iris_scale (default 1.0) to match size differences.
  • Pixels outside the aligned restore support are copied byte-for-byte from the generated image - nothing else from the source leaks in.

Outputs: restored_local (the fixed crop), iris_restore_alpha (the paste mask, useful for inspection), preview, and report_json.

Inputs that matter

  • source_landmarks / generated_landmarks - both required; the whole trick depends on having corresponding face geometry in each image.
  • iris_scale - 0.65 to 1.5. If the AI made bigger eyes, nudge this up; if the pasted iris looks too big, down.
  • feather_pixels - keep it small (default 3). Too much feather and the iris material bleeds into the sclera; too little and you get a visible disc.
  • crop_x / crop_y - the crop's origin in the full image, forced inputs from upstream.

Install

ComfyUI Manager → search "Region Edit Toolkit" (package ID native-region-tile-planner-merge) → install → restart. Or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip install -r requirements.txt into ComfyUI's Python, restart. Python 3.10+, deps numpy/Pillow/scipy/argostranslate. No models bundled - face landmarks come from your existing face-detection setup.

Gotchas

The node needs at least 467 MediaPipe-style landmarks for the eye interior work; if your detection chain outputs a 68-point set, it will throw. And the generated image has to actually have usable eye geometry - if the model closed the eyes or drew them in a radically different spot, the mapping gets strained and you'll see it in the preview. That's what preview is for: look at it before you wire the result into the composite. The contract_version string is version-locked; leave it unless you're upgrading workflows across pack versions.

CategoryRegion Edit Toolkit/Face

Inputs (12)

NameTypeDefaultDescription
source_localIMAGE
generated_localIMAGE
local_generation_maskMASK
source_landmarksFACE_LANDMARKS
generated_landmarksFACE_LANDMARKS
source_face_indexINT00–15
generated_face_indexINT00–15
crop_xINT
crop_yINT
iris_scaleFLOAT1.000.65–1.5
feather_pixelsFLOAT3.00–32
source_eye_material_restore_contract_versionoptSTRINGface-local-source-gaze-aligned-iris-material-v3

Outputs (4)

NameTypeDescription
restored_localIMAGE
iris_restore_alphaMASK
previewIMAGE
report_jsonSTRING