Filters: Heal / Content-Aware Fill
Content-Aware Fill, Inside ComfyUI, Same Result Every Time
- image
- mask
- image
Removing a wire from a sky in ComfyUI used to mean one of two things: an inpaint model pass, which invents plausible content and occasionally invents a new building, or a manual clone stamp in a different application. Filters: Heal / Content-Aware Fill (JHPixelProHeal) is the third option - exemplar-based inpainting, the same family of algorithm as Photoshop's Content-Aware Fill, running in the graph.
The trade you're making is the honest one: no model, no seed lottery, no diffusion pass. The fill is built from the photo's own pixels, and the same mask gives you the same result every run.
The mechanism
mode = content_aware is exemplar-based completion (Wexler, Shechtman & Irani 2007) with a parallel PatchMatch search (Barnes et al. 2009). The hole is filled coarse-to-fine over an image pyramid. At each level, every pixel whose 7×7 patch touches the hole searches for the most similar fully-known patch nearby - propagation from neighbours at 8/4/2/1 px jumps, plus random search at shrinking radii. Each hole pixel then becomes a weighted vote of all the overlapping source patches, which is how texture and structure continue into the hole instead of stopping at its edge.
Only the area around each part of the mask gets processed - its bounding box plus a margin set by context - and memory grows with that area only. Parts of a mask that are far apart are healed separately, each with its own search area. The feather band is synthesised too, then blended from opaque at the mask edge to original at the outer edge of the band.
mode = smooth is the opposite: normalised convolution from the surrounding colours, no texture. Fast and safe for flat areas.
What you set
image and mask - white = remove and fill.
mode (content_aware / smooth, default content_aware).
grow (0–64, default 2) - pixels added around the mask so the object's halo and shadow go with it. For a long wire across sky, a thin mask with grow 3–6 usually does it.
feather (0–32, default 1.5) - soft blend at the edge of the filled area, in pixels.
context (0.25–8, default 1) - how far around the mask to look for material, as a multiple of the mask size. This is the one you'll actually tune: raise it when the right texture is far away (a wire over a large even sky), lower it when the fill starts repeating an unwanted pattern.
Output: image.
Where it's good and where it isn't
Good on texture: skin, sky, grass, sand, walls, fabric. Mask out a scar, a logo on a flat wall, a small object on grass, and it disappears convincingly.
Bad on structure: arches, lettering, faces, anything with a strong regular pattern that must continue correctly. On those, mask generously, push context up, and expect to retouch by hand afterwards. That's a property of the algorithm, not a bug in the node - exemplar methods are excellent at "more of the same texture" and indifferent to semantics.
The single most common cause of a bad fill is masking too little. Leftover edges of the removed object are what make a fill look fake; a slightly generous mask costs you nothing.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/ComfyUI-JH-PixelPro.git
cd ComfyUI-JH-PixelPro
pip install -r requirements.txt # the Python that runs ComfyUI
ComfyUI Manager: search ComfyUI-JH-PixelPro → Install → restart → Add Node → ComfyUI-JH-PixelPro → filters. Requirements: kornia>=0.7, mediapipe>=0.10.33, opencv-python-headless>=4.8, scipy>=1.10, PyTorch from ComfyUI. Nothing downloads. On a GPU, 1–3 s for typical masks on an 8 MP photo, under 1.1 GB VRAM at 4K. On CPU it's a different sport: about 25 s for a 400 px hole at 4K.
Where people get burned
- Smeared, low-detail fill. You're in
content_awarebut the hole is huge relative to its context. Raisecontextor split the removal into several smaller masks. - Repeating pattern in the fill. Lower
context. PatchMatch found one good patch and voted for it too often. - A visible rectangle where the object's shadow was.
growwas too small. Bump it. - The mask isn't touching the object's edge. Mask a bit more than the thing you're removing, not exactly it.
- CPU and a big mask. Queue it and go make tea. 25 s is not a hang.
Pick the right remover, though - this pack ships three and they're not interchangeable. Dust & Spot Removal finds and heals small specks by itself. Auto Blemish finds faces and heals marks on skin. This node is for you deciding what goes, and it being rebuilt from the surroundings.
Pack: Apache-2.0, JH (@jetthuangai), v1.10.0 / 64 nodes, docs EN + VI. No Reddit footprint to consult - searching the pack name in the corpus returns a single unrelated Chrome extension - so trust the measured speed numbers in the changelog and your own eyes.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Photo to retouch. | |
| mask | MASK | White = remove and fill (wires, objects, blemishes, logos). | |
| mode | COMBO | content_aware | content_aware = rebuild texture and structure from nearby patches (like Photoshop Content-Aware Fill). smooth = soft colour fill, for flat areas. |
| grow | INT | 20–64 | Pixels added around the mask so halos and shadows of the object go too. |
| feather | FLOAT | 1.50–32 | Soft blend at the edge of the filled area, in pixels. |
| contextopt | FLOAT | 1.000.25–8 | How far around the mask to look for material, as a multiple of the mask size. Raise it when the right texture is far away. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |