Nodes/tri3d-comfyui-nodes/Position Parts Batch v5.1.0
ComfyUI Node

Position Parts Batch v5.1.0

Paste garment parts back onto a person using ATR segmentation colors

By TRI3D-LC·Created 3 years ago·Updated about a year ago· 27
Position Parts Batch v5.1.0
  • batch_images
  • batch_segs
  • batch_handimgs
  • IMAGE
margin15
right_legfalse
right_handtrue
headfalse
hairfalse
left_shoefalse
bagfalse
backgroundfalse
dressfalse
left_legfalse
right_shoefalse
left_handtrue
upper_garmentfalse
lower_garmentfalse
beltfalse
skirtfalse
hatfalse
sunglassesfalse
scarffalse

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:

  1. Finds the bounding box of all pixels matching those colors in the segmentation map.
  2. Resizes the corresponding part image (from batch_handimgs) to fill that box.
  3. Runs an unsharp mask on it - a light sharpen so the pasted patch doesn't look blurry against the photo.
  4. 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 image i's part lands on image i.
  • 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_segs visually.
  • 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.

CategoryTRI3D

Inputs (22)

NameTypeDefaultDescription
batch_imagesIMAGE
batch_segsIMAGE
batch_handimgsIMAGE
marginINT15
right_legBOOLEANfalse
right_handBOOLEANtrue
headBOOLEANfalse
hairBOOLEANfalse
left_shoeBOOLEANfalse
bagBOOLEANfalse
backgroundBOOLEANfalse
dressBOOLEANfalse
left_legBOOLEANfalse
right_shoeBOOLEANfalse
left_handBOOLEANtrue
upper_garmentBOOLEANfalse
lower_garmentBOOLEANfalse
beltBOOLEANfalse
skirtBOOLEANfalse
hatBOOLEANfalse
sunglassesBOOLEANfalse
scarfBOOLEANfalse

Outputs (1)

NameTypeDescription
IMAGEIMAGE