Nodes/Region Edit Toolkit/图像分区 · 保留约束 Prompt 构建
ComfyUI Node

图像分区 · 保留约束 Prompt 构建

Stop forgetting the 'keep everything else unchanged' clause on every regional edit

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 保留约束 Prompt 构建
    • complete_prompt
    edit_instructionRemove the selected object.

    The least glamorous cause of ruined regional edits is a prompt that never said "leave the rest alone." You describe the removal, you don't describe everything that must survive, and the model - which sees the whole crop as fair game - reimagines the wall, the lighting, or the grain along with the object you meant to delete. RegionEditPreservationPromptBuilder exists to make that clause impossible to forget. It takes your edit_instruction and appends a fixed preservation sentence to it, producing a complete_prompt.

    The appended text is worth quoting, because it's a good model of what an edit model actually needs to hear:

    "Keep everything outside the selected mask unchanged. Inside the selected mask, reconstruct only the requested result and match the surrounding material, texture, color, lighting, sharpness, and image grain. Do not introduce unrelated objects, patterns, or materials."

    That's the author's framing of the preservation problem, and it's genuinely well-targeted: it tells the model what to leave alone, how to match what it rebuilds, and what not to add. For instruction-editing models (Flux Kontext, Qwen-Image-Edit, and the FLUX.2 Klein path this pack is built around), this kind of explicit constraint is exactly what separates "remove the cable" from "remove the cable and invent a poster."

    The implementation has a thoughtful detail: the suffix is idempotent. If your edit_instruction already contains that preservation text, the node returns it unchanged instead of doubling it up. That means you can run your prompt through this node more than once, or combine prompts that already carry the clause, and never get the prose equivalent of a stack overflow.

    Inputs and outputs are minimal by design - one multiline edit_instruction (default "Remove the selected object.") in, one complete_prompt out. This is a plumbing node in the best sense: it's a place to centralize the one sentence every regional prompt needs, so you type it zero times instead of pasting it into ten text boxes. In the pack's object-replacement workflow it slots in right after the replacement prompt contract, feeding the same Klein conditioning branch.

    Install: ComfyUI Manager → search Region Edit Toolkit (registry ID native-region-tile-planner-merge), or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip-install requirements.txt into ComfyUI's actual Python, restart. No models, no downloads - it's string concatenation with a brain.

    Two honest caveats. First, a preservation clause is a request, not a guarantee - Klein and friends are better at honoring it than a plain SDXL inpaint, but "keep unchanged" is a soft constraint that can still leak. Second, this is an English-language clause; if your edit instruction is Chinese and you're running it through the toolkit's offline translation first, translate then append so the preservation text stays in the model's working language. That's the ordering the pack's own workflows follow, and it's worth copying.

    CategoryRegion Edit Toolkit/Text

    Inputs (1)

    NameTypeDefaultDescription
    edit_instructionSTRINGRemove the selected object.

    Outputs (1)

    NameTypeDescription
    complete_promptSTRING