图像分区 · 人脸语义裁块
The one node that plans the entire face edit — crop, mask, coordinates, and all
- image
- selection
- final_target_mask
- protection_mask
- local_image
- local_generation_mask
- full_composite_mask
- full_composite_alpha
- x
- y
- width
- height
- crop_preview
- report_json
If the face pipeline in this pack had a centerpiece, it's this node. RegionEditFaceSemanticCrop is where a face edit stops being a pile of masks and crops and becomes a plan: it takes the selected face, your final target mask, and your protection mask, and produces the local crop, the generation mask, the composite masks, and the exact coordinates - everything the strict composite needs later, all consistent with each other by construction. It's the biggest node in the pack (ten outputs, a dozen-plus inputs) and the one where the design philosophy is most visible.
The philosophy, in one line: the edit region is a broad semantic head region, not a tight face oval. The pack's README and the code are explicit - the region deliberately includes bangs, the hairline, ears, and upper neck, because an edit that cuts bangs at a mask edge or draws a straight line across hair is the #1 way a face edit announces itself. Crop and mask are planned together so that doesn't happen.
How it works
It consumes the selection from RegionEditFaceSelect, the final_target_mask (your composed target), and a protection_mask. Then:
edit_region_modepicks the region shape: the recommended broad head semantic region, or the legacy face-ellipse-plus-expansion for older workflows.tile_profilesets the generation size: 标准 (standard, single face), 大块 (large tile, high VRAM), or 超大块 (huge, RTX 4090 territory). This is a preset for how much context the generation gets.context_left_right/context_top/context_bottom(defaults 0.65) scale how much room around the head is included - relative to face size, so it adapts.generation_grow_ratio,composite_grow_ratio,feather_ratiocontrol how far the generation region, the composite region, and the feather extend past the target mask. The generation region gets more room than the composite region - the model sees more, the paste is tighter.minimum_safe_margin(default 64) keeps the crop away from the tile's VAE boundary.
The optional context_policy is where you pick your reality: strict source-head editing (default), source-edge-compatible (allows cropping at the image edge), or identity-reference-face (prioritize complete features for a reference crop).
Outputs
The useful ten: local_image (the crop to edit), local_generation_mask (what the model should regenerate), full_composite_mask and full_composite_alpha (the full-image masks for the final paste), x/y/width/height (the crop rect, carried along for the strict composite), crop_preview, and report_json. Edit local_image → run your pass → hand the result plus these coordinates and masks to RegionEditStrictCoordinateComposite.
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 bundled models.
Gotchas
Start with the profiles and defaults and change one thing at a time - there are a lot of knobs and they're correlated. If your edit shows seams at the hairline, you've probably got generation_grow_ratio and composite_grow_ratio too close together (the generation needs room the composite doesn't). And if the node errors about the crop touching the tile boundary, raise minimum_safe_margin rather than lowering your context - the VAE boundary is a real constraint. generation_target_megapixels defaults to 0 (auto); only set it if your model has a hard ceiling you need to respect.
Inputs (16)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| selection | FACE_LOCAL_SELECTION | — | |
| final_target_mask | MASK | — | |
| protection_mask | MASK | — | |
| edit_region_mode | COMBO | 宽松头部语义区(推荐) | 2 options: 宽松头部语义区(推荐), 旧版脸椭圆外扩(兼容) |
| tile_profile | COMBO | 大块(高显存) | 3 options: 标准(单脸), 大块(高显存), 超大块(RTX 4090) |
| context_left_right | FLOAT | 0.650.2–1.5 | — |
| context_top | FLOAT | 0.650.3–1.5 | — |
| context_bottom | FLOAT | 0.650.3–1.5 | — |
| generation_grow_ratio | FLOAT | 0.100–0.35 | — |
| composite_grow_ratio | FLOAT | 0.060–0.25 | — |
| feather_ratio | FLOAT | 0.0300–0.1 | — |
| minimum_safe_margin | INT | 6432–512 | — |
| context_policyopt | COMBO | 源图头部编辑(严格上下文) | 3 options: 源图头部编辑(严格上下文), 源图边缘兼容(裁边不中止), 身份参考脸(完整五官优先) |
| writeback_scope_contract_versionopt | STRING | phase1-head-upper-neck-v1 | — |
| generation_target_megapixelsopt | FLOAT | 0.00–64 | — |
Outputs (10)
| Name | Type | Description |
|---|---|---|
| local_image | IMAGE | — |
| local_generation_mask | MASK | — |
| full_composite_mask | MASK | — |
| full_composite_alpha | MASK | — |
| x | INT | — |
| y | INT | — |
| width | INT | — |
| height | INT | — |
| crop_preview | IMAGE | — |
| report_json | STRING | — |