jz Seam Repair
Kill the One-Pixel Fill-Color Rim Gemini Leaves Behind
- generated_image
- outpaint_mask
- fill_color
- image
- residue
You know the tell. Gemini happily outpaints your padded canvas, but at the very edge of the image there's a hairline strip of the padding color - a thin rim that never quite got filled. Zoom in and it's a colored border around your finished image. Gemini Fill Seam Repair is a deterministic little cleanup node that erases exactly that, with zero API calls.
It's a niche tool in an already-niche pack, and it only earns its keep in the specific setup it was built for: outpaint with the Gemini API, pad with Gemini Pad Calculator, and generate with Gemini Image Generate. If you're doing that, this node fixes the one artifact those models reliably leave.
How it works
The trick is that the fill color was chosen to be absent from your image. If you used fill_mode: unique on the pad calculator, the padding is a color that cannot occur naturally in the scene (magenta first, then a KDTree search for the farthest absent color). So after generation, any remaining fill-colored pixel is pure artifact - not content.
The node compares the generated image against the fill color within a tolerance (tol, default 80) and measures what fraction of the entire outpaint region is still fill-colored. That's the residue. Then the logic forks:
- Residue small (≤ max_fraction, default 0.01 = 1%) - that's the thin seam. The node looks only at the outermost edge_band pixels (default 5) of the canvas, within the outpaint region, uses a generous repair_tol (120) so it catches the whole rim, optionally dilates the bad area (default 3), then copies the nearest good pixel's color in using a distance transform. Deterministic, fast, no model.
- Residue large - the model echoed the entire padding instead of outpainting. That's a real failure, and the node deliberately leaves it alone rather than smear colors around. You want to see that failure; seam repair can't fix "the model drew the whole canvas magenta."
Inputs and outputs
- generated_image - Gemini's output.
- outpaint_mask - wire from Gemini Pad Calculator's
outpaint_mask(MASK). If its resolution differs from the image, the node resizes it with nearest-neighbor, so wiring mismatches are handled. - fill_color - the solid fill-color IMAGE from Gemini Pad Calculator's
fill_coloroutput. This is how the node knows what "leftover pad" looks like. - The image output is your cleaned result. The residue output is a FLOAT - the fraction of fill-colored pixels over the outpaint region. It's the diagnostic you should actually read: residue near zero means the outpaint worked and the seam was cosmetic; residue of 0.3 means the whole outpaint failed and no amount of seam repair helps.
Defaults (tol 80, max_fraction 0.01, repair_tol 120, edge_band 5, dilate 3) are tuned for the seam case and are worth leaving alone until you've seen it misbehave.
Install
Same pack install as the rest - no extra dependencies beyond scipy, which the pack needs regardless:
# ComfyUI Manager → search "ComfyUI-Outpainting-Gemini", or:
cd ComfyUI/custom_nodes
git clone https://github.com/jzhang-POP/ComfyUI-Outpainting-Gemini
source ../venv/bin/activate && pip install scipy # if not already present
Restart ComfyUI. Note the README's install URL is a broken YOUR_USERNAME/... placeholder - use the repo URL above.
Troubleshooting
- Nothing ever gets repaired - you're probably on
edge_averagefill mode, so the "fill color" also appears in the image edges and the residue check gets confused. Switch the pad calculator tofill_mode: unique; this node assumes it. - Residue output is high and the image looks wrong - that's the model echoing the pad, not a seam problem. Change the prompt (Gemini Prompt Builder exists for exactly this) or the model, not the repair settings.
- A faint seam persists - raise repair_tol or edge_band, or bump dilate so the fix bleeds past the rim.
One small, well-behaved node. It won't rescue a failed outpaint - it only polishes a successful one - but that's the right job to automate.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| generated_image | IMAGE | — | |
| outpaint_mask | MASK | — | |
| fill_color | IMAGE | — | |
| tol | INT | 800–255 | — |
| max_fraction | FLOAT | 0.0100–1 | — |
| repair_tol | INT | 1200–255 | — |
| edge_band | INT | 51–128 | — |
| dilate | INT | 30–64 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| residue | FLOAT | — |