Nodes/ComfyUI-DAELab-Custom-Nodes-Library/Badge Semantic Region GPT Channel V1
ComfyUI Node

Badge Semantic Region GPT Channel V1

One paid edit, behind a very strict gate

By TeutonicMepheles·Created 4 months ago·Updated 3 days ago· 0
Badge Semantic Region GPT Channel V1
  • base_image
  • region_mask
  • foreground_mask
  • region_image
  • validated_mask
  • call_status
◄enabledfalse►
◄edit_promptRefine the selected region while preserving its original color and boundaries.►
◄qualitymedium►
◄reroll_revision0►
◄minimum_region_pixels16►

If you've built anything with GPT Image 2 in ComfyUI you know the rhythm: you tweak a mask, queue, and something invisible spends money. This node's entire reason to exist is to put a bouncer in front of that. It is one local semantic repaint against one immutable base image, and it refuses to spawn the billable API node unless it has something worth spending on.

Read the description in the node itself: "Disabled, empty, or tiny masks return the immutable base without expanding a billable API node." That's the contract.

How it works

Three inputs decide everything: base_image, region_mask, foreground_mask. The node intersects the region with the foreground and hard-thresholds at 0.5, because a mask that leaks outside the badge is not a mask you wanted. It then counts pixels and compares against minimum_region_pixels (default 16).

If enabled is false, if the intersection is empty, or if it's below that pixel floor, you get base_image back untouched, an all-zero mask, and a call_status JSON string saying why - disabled or empty_or_too_small_mask. Realistically nothing happens, which is the correct outcome and costs nothing.

If it passes, the node expands a native OpenAIGPTImageNodeV2 child at 1024×1024, opaque background, gpt-image-2, with your base as Image 1 and the validated mask as the edit mask, then feeds the result through a deterministic composite so that only the mask's interior can change. The prompt is generated, not authored: it names Image 1 as the only reference, forbids everything outside the white mask from moving, and pins canvas, camera, framing, silhouette, geometry, text, typography, linework, region boundaries, neighbouring materials and background. Your edit_prompt gets appended as a single LOCAL EDIT INSTRUCTION: line at the end.

That prompt scaffolding is why this node is opinionated and useful. Anyone who has asked GPT Image 2 to "just change the enamel texture" has watched it redesign the whole badge; the constraint text is the accumulated fix for that.

reroll_revision is passed to the child node as its seed, so bumping the integer gives you a fresh sample - and the child's own cache means an unchanged revision with unchanged inputs won't bill you twice.

In and out

Beginner-relevant inputs: enabled (defaults to false - you have to turn it on, deliberately), edit_prompt, and quality (low/medium/high, default medium; high costs more credits). Everything else is safety rail.

  • region_image - the composited result. This is what goes into the merge node.
  • validated_mask - the foreground-clipped mask actually used. Feed the same mask into the merge node so the report and the pixels agree.
  • call_status - JSON with gpt_node_used, billable_api_request_on_cache_miss, selected_pixels, quality, reroll_revision, reason, the mask polarity (white_is_edited) and the reference-image count. Log it; it's your receipt.

The honest cost story

Every active channel is one GPT Image 2 call on a cache miss, billed against your Comfy account credits, not an OpenAI key. A four-channel badge edit is four calls. That's the whole design premise of pairing this with the merge node: four separate, individually cacheable edits instead of one giant prompt that either does everything or does nothing.

This pack is essentially invisible in the community corpus - no threads mention DAELab - so there are no tutorials to lean on here. Read the status JSON instead. It's more informative than a blog post would be.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library.git

Restart ComfyUI, refresh the browser. This is a V3 node built on comfy_api.latest, so an older ComfyUI core will fail at import with No module named 'comfy_api' - the fix is updating ComfyUI, not pip-installing something called comfy_api. You'll also need to be signed in to a Comfy account, because the child GPT Image 2 node runs on partner-node credits.

Gotchas

base_image, region_mask and foreground_mask must share a canvas. Different sizes raise a ValueError instead of resizing - normalise first, then mask.

The default enabled=false is the number one "the node does nothing" report. Check call_status; it names the reason explicitly rather than failing silently.

Small regions are not worth paying for. Sixteen pixels of mask gets you a GPT call that will either ignore the edit or hallucinate a bigger region to work with. Draw a real selection with the pack's mask node, and use the merge node's report to confirm outside_max_abs_diff stayed at zero.

CategoryDAELab/Badge/PP

Inputs (8)

NameTypeDefaultDescription
base_imageIMAGE—
region_maskMASK—
foreground_maskMASK—
enabledBOOLEANfalse—
edit_promptSTRINGRefine the selected region while preserving its original color and boundaries.—
qualityCOMBOmedium3 options: low, medium, high
reroll_revisionINT00–2147483647—
minimum_region_pixelsINT161–65536—

Outputs (3)

NameTypeDescription
region_imageIMAGE—
validated_maskMASK—
call_statusSTRING—