NH Agnostic Image Generator
Garment erased, model fooled
- image
- mask
- agnostic_img
- masked_img
- composite
If you've ever fed a virtual-try-on or inpaint workflow an image where the garment is still visible under the mask, you know the problem: the model cheats. It sees the old shirt, leans on it, and the new shirt comes out half old. "Agnostic" in VTON-speak means the garment is gone - the masked region is replaced with something the model can't copy, so it has to invent the replacement honestly. That's exactly what NH Agnostic Image Generator does, and it does it in one node.
Give it an image and a mask (any mask will do - from Garment Segment (NH), a painted mask, or a segmentation model), pick a fill, and it hands you three images.
How it works
The mechanism is boring in the best way. The node reads your mask, turns anything above 0.5 into an alpha region, and then blends that region with one of three fills:
- gray - flat fill at
gray_value(0.5 is a mid-grey). This is the classic inpaint trick: solid color forces the model to invent rather than lean on pixels that are there. - noise - random noise blended with the grey, so the region looks like "something unreadable" instead of "a void." Helpful when flat gray reads too artificial to your model.
- blur - a heavy Gaussian blur of the original pixels (radius from
blur_radius, default 65). This keeps the rough composition and lighting but destroys the garment detail - the right choice when you want the model to change only detail, not redraw the whole scene.
feathering (0–100) softens the mask edge before filling, which is the same mask-blur trick the inpainting playbook swears by to avoid a hard seam. Even a few pixels of feathering kills most visible edges.
The three outputs and what to do with them
- agnostic_img - the filled image. This is the one your inpaint/VTON sampler actually consumes.
- masked_img - the original with the mask region knocked out to white. Useful for eyeballing exactly what got covered, or as an input for compositing steps that want transparency math.
- composite - a debug preview: left half is the original with a green mask outline, right half is the agnostic result, split down the middle. Wire this to a preview node while you tune settings, then unplug it.
For the standard flow: Load Image → Garment Segment (NH) → NH Agnostic Image Generator → (inpaint sampler).
Installing
This one needs no models - it's pure numpy/OpenCV math. Install the pack once and it just works:
cd ComfyUI/custom_nodes
git clone https://github.com/jetthuangai/NH-Nodes.git
cd NH-Nodes
pip install -r requirements.txt
Or search NH-Nodes in ComfyUI Manager and restart. If you're coming from another pack's "agnostic image" node, the settings you'll actually touch are fill_mode and feathering; the rest have sane defaults.
One honest caveat: an "agnostic" image is a VTON preprocess step, not a magic bullet. If your try-on output still bleeds the old garment, the problem is usually the mask (too tight, or it caught the armhole) rather than the fill - check composite before blaming this node.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — | |
| fill_mode | COMBO | 3 options: gray, noise, blur | |
| blur_radius | INT | 653–255 | — |
| noise_strength | FLOAT | 1.000–1 | — |
| gray_value | FLOAT | 0.500–1 | — |
| feathering | INT | 00–100 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| agnostic_img | IMAGE | — |
| masked_img | IMAGE | — |
| composite | IMAGE | — |