Badge Deterministic Composite (DAELab)
Paste the edit back and prove nothing else moved
- previous_master
- edit_candidate
- edit_mask
- edited_master
- outside_max_diff
- outside_mean_diff
- boundary_diagnostic
- report
What it is and why you'd reach for it
If you have ever chained three instruction edits on the same image and watched the detail quietly rot, you know the problem this node exists for. A whole-frame edit model takes the entire picture as context and hands back an entire new picture. The pixels you didn't ask about come back close. Not identical. Do that five times and your badge's 6pt type has drifted half a pixel per step and softened into mush.
Badge Deterministic Composite is a three-input opacity paste with a paranoid streak. It takes the previous master, the new candidate, and the mask you actually selected, and it keeps the candidate only where the mask is white. Everywhere else the original bytes survive untouched - and then it checks that they did and raises an exception if they didn't. On a GPT-Image-2 edit chain, where each hop is a metered API call, that guarantee is the difference between an iterative workflow and a workflow that only works once.
How it works
Straight alpha blend, no feathering: edited = mask * candidate + (1 - mask) * previous. The mask is broadcast to the image batch, must be binary - anything between 0 and 1 raises - and must match the canvas exactly. No resize is attempted, on purpose. If your mask is 1024² and your candidate is 1536², that's a bug upstream and you want to hear about it.
Then the assertion: outside_difference = |edited - previous| * (1 - mask) is computed, and if the maximum of that is anything other than exactly zero, the node raises Deterministic composite violated the zero-difference outside-mask contract. In practice that's unreachable with a valid binary mask, which is the point - the check is there so that if someone later "improves" the blend with a feather or a colour match, the workflow falls over loudly instead of shipping soft edges.
The boundary_diagnostic output overlays the mask's gradient edge in yellow on the composited result, so you can see the seam you're actually creating. On a badge with a hard enamel boundary you want that line to sit on a real artwork edge, not across a flat field.
Inputs and outputs that matter
Three required inputs, no widgets at all - unusual, and pleasant. previous_master is the currently approved badge, edit_candidate is what the generative node returned, edit_mask is the validated selection coming out of Badge Edit Mask Validator (its edit_mask output, already intersected with the design foreground - that pre-clipping is why you can trust this node's contract).
Outputs: edited_master continues the chain or goes to a save node. outside_max_diff and outside_mean_diff are your QA numbers and should read 0 and 0; if you're feeding this into a report node, they're the receipt. boundary_diagnostic for eyeballs, report for a JSON log with mask_polarity: "white_is_edited".
One naming trap: white is the edit region, not the protected region. This pack is internally consistent about that, but half the masking tools in the ComfyUI ecosystem are not, and a couple of pack versions even inverted it. Check with a deliberately tiny mask before you spend credits.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/TeutonicMepheles/ComfyUI-DAELab-Custom-Nodes-Library
Then restart. Manager works too - search the pack title. The badge nodes need OpenCV (import cv2 in the module) which the pack's requirements.txt doesn't declare, so pip install opencv-python-headless if the node doesn't appear in the menu. You also need a reasonably current ComfyUI: parts of this pack use the V3 comfy_api.latest authoring API, which older builds don't ship.
Common issues
edit mask must match the image canvas exactly. Your candidate came back at a different resolution than the master. Put the registration/canvas-normalize node back in front of it - this node deliberately won't paper over a size mismatch.edit_mask must be binary. You're feeding a soft mask from a blur or a colour-distance mask with antialiased edges. Threshold it or run it through the validator first.previous master and edit candidate must have identical batch. Batch size 1 vs batch size 4.n=1on the GPT node and one image on the master.- Nothing appears different. The mask is empty. That's legal here (you get the master back verbatim), and in the full workflow
Badge Edit Mask Validatoris supposed to route empty selections around the paid call before you get this far.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| previous_master | IMAGE | — | |
| edit_candidate | IMAGE | — | |
| edit_mask | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| edited_master | IMAGE | — |
| outside_max_diff | FLOAT | — |
| outside_mean_diff | FLOAT | — |
| boundary_diagnostic | IMAGE | — |
| report | STRING | — |