图像分区 · 眼内材质恢复
Put the original irises back into the AI's eyes, without a pasted-eye look
- source_local
- generated_local
- local_generation_mask
- source_landmarks
- generated_landmarks
- restored_local
- iris_restore_alpha
- preview
- report_json
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_pixelsedge (default 3) and aniris_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.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| source_local | IMAGE | — | |
| generated_local | IMAGE | — | |
| local_generation_mask | MASK | — | |
| source_landmarks | FACE_LANDMARKS | — | |
| generated_landmarks | FACE_LANDMARKS | — | |
| source_face_index | INT | 00–15 | — |
| generated_face_index | INT | 00–15 | — |
| crop_x | INT | — | |
| crop_y | INT | — | |
| iris_scale | FLOAT | 1.000.65–1.5 | — |
| feather_pixels | FLOAT | 3.00–32 | — |
| source_eye_material_restore_contract_versionopt | STRING | face-local-source-gaze-aligned-iris-material-v3 | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| restored_local | IMAGE | — |
| iris_restore_alpha | MASK | — |
| preview | IMAGE | — |
| report_json | STRING | — |