Position Parts Batch v5.1.0
Paste garment parts back onto a person using ATR segmentation colors
- batch_images
- batch_segs
- batch_handimgs
- IMAGE
Virtual try-on is really a multi-stage relay: detect the person, separate the parts, warp the garment, then put the pieces back where they belong. That last job is what this node is for. It takes a batch of photos, their ATR human-parsing segmentation maps, and a batch of "part images" - the warped or extracted garment bits - and pastes each part onto the photo at exactly the spot its segmentation color says it belongs.
Where it shines is batch: every image in the batch gets the same treatment in one pass, which is what you want when you're processing a whole catalog of mannequin shots through a warper.
How it works
The node speaks the ATR color language. ATR (Adaptive Task Region) human parsing labels pixels with specific RGB values - upper garment is [0,0,128], lower garment [0,128,128], right hand [192,128,128], left hand [64,128,128], and so on. You tell it which parts you care about by flipping booleans, it builds a color list, then for each image:
- Finds the bounding box of all pixels matching those colors in the segmentation map.
- Resizes the corresponding part image (from
batch_handimgs) to fill that box. - Runs an unsharp mask on it - a light sharpen so the pasted patch doesn't look blurry against the photo.
- Blits it into the photo at that position.
Output is one IMAGE batch: the photos with the selected parts composited in. Two parts are on by default - right_hand and left_hand - because the common pipeline detects hands with a separate hand-specific model and needs a home for those images. Everything else (upper_garment, lower_garment, hair, shoes, hat, scarf, dress, belt, skirt, bag, sunglasses, background, head, legs) is off until you ask.
The inputs that matter
batch_images- the person photos.batch_segs- ATR segmentation maps, same batch size, same resolution as the photos. If yours come from a different parser, the colors won't match and nothing will paste.batch_handimgs- the parts to paste. These are keyed by position in the batch, so imagei's part lands on imagei.margin(INT, default 15) - padding around the paste region.- The part toggles - flip on exactly the parts whose images you're feeding.
Installing it
Part of the same pack, one install covers everything:
cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
cd tri3d-comfyui-nodes
pip install -r requirements.txt
or ComfyUI Manager → "tri3d-comfyui-nodes". Restart, find it under TRI3D. This node only needs OpenCV + numpy, but the pack's requirements drag in a lot more.
Common issues
- Nothing gets pasted - either the seg map isn't ATR-colored (most common), the toggle for the part you're feeding is off, or the color isn't present in the map for that image. Check
batch_segsvisually. - Wrong part, wrong spot - the part images must line up with the seg map's coordinate space; if your seg map is a different resolution than the photo, the node resizes it, and mismatched dimensions produce sloppy boxes.
- Only hands work while the garment doesn't - the two hand toggles are on by default and the garment ones aren't. That's not a bug, but it trips up everyone once.
If you're already using tri3d-extract-parts-batch earlier in the pipeline, this node is its natural bookend - extract with one, position with the other.
Inputs (22)
| Name | Type | Default | Description |
|---|---|---|---|
| batch_images | IMAGE | — | |
| batch_segs | IMAGE | — | |
| batch_handimgs | IMAGE | — | |
| margin | INT | 15 | — |
| right_leg | BOOLEAN | false | — |
| right_hand | BOOLEAN | true | — |
| head | BOOLEAN | false | — |
| hair | BOOLEAN | false | — |
| left_shoe | BOOLEAN | false | — |
| bag | BOOLEAN | false | — |
| background | BOOLEAN | false | — |
| dress | BOOLEAN | false | — |
| left_leg | BOOLEAN | false | — |
| right_shoe | BOOLEAN | false | — |
| left_hand | BOOLEAN | true | — |
| upper_garment | BOOLEAN | false | — |
| lower_garment | BOOLEAN | false | — |
| belt | BOOLEAN | false | — |
| skirt | BOOLEAN | false | — |
| hat | BOOLEAN | false | — |
| sunglasses | BOOLEAN | false | — |
| scarf | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |