Nodes/Region Edit Toolkit/图像分区 · 人脸语义裁块
ComfyUI Node

图像分区 · 人脸语义裁块

The one node that plans the entire face edit — crop, mask, coordinates, and all

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 人脸语义裁块
  • 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
edit_region_mode宽松头部语义区(推荐)
tile_profile大块(高显存)
context_left_right0.65
context_top0.65
context_bottom0.65
generation_grow_ratio0.10
composite_grow_ratio0.06
feather_ratio0.030
minimum_safe_margin64
context_policy源图头部编辑(严格上下文)
writeback_scope_contract_versionphase1-head-upper-neck-v1
generation_target_megapixels0.0

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_mode picks the region shape: the recommended broad head semantic region, or the legacy face-ellipse-plus-expansion for older workflows.
  • tile_profile sets 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_ratio control 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.

CategoryRegion Edit Toolkit/Face

Inputs (16)

NameTypeDefaultDescription
imageIMAGE
selectionFACE_LOCAL_SELECTION
final_target_maskMASK
protection_maskMASK
edit_region_modeCOMBO宽松头部语义区(推荐)2 options: 宽松头部语义区(推荐), 旧版脸椭圆外扩(兼容)
tile_profileCOMBO大块(高显存)3 options: 标准(单脸), 大块(高显存), 超大块(RTX 4090)
context_left_rightFLOAT0.650.2–1.5
context_topFLOAT0.650.3–1.5
context_bottomFLOAT0.650.3–1.5
generation_grow_ratioFLOAT0.100–0.35
composite_grow_ratioFLOAT0.060–0.25
feather_ratioFLOAT0.0300–0.1
minimum_safe_marginINT6432–512
context_policyoptCOMBO源图头部编辑(严格上下文)3 options: 源图头部编辑(严格上下文), 源图边缘兼容(裁边不中止), 身份参考脸(完整五官优先)
writeback_scope_contract_versionoptSTRINGphase1-head-upper-neck-v1
generation_target_megapixelsoptFLOAT0.00–64

Outputs (10)

NameTypeDescription
local_imageIMAGE
local_generation_maskMASK
full_composite_maskMASK
full_composite_alphaMASK
xINT
yINT
widthINT
heightINT
crop_previewIMAGE
report_jsonSTRING