Extract Masks Batch v5.1.0
Turn ATR segmentation maps into the exact masks you need (and only those)
- batch_segs
- MASK
Once you've run the pack's ATR parse on a batch, you've got 18 classes of body parts and garments sitting in one colored map per image. tri3d-extract-masks-batch is the picker: a wall of booleans, one per ATR class, and it returns a single MASK batch containing exactly the classes you ticked, combined. It's the node you reach for when you need a head mask, a hands mask, a hair mask, or an "everything that's not the garment" mask for an inpainting step.
What it does
One image input - batch_segs, the palette-colored segmentation maps straight from tri3d-atr-parse-batch. Then eighteen booleans, one per class:
head,hair,hat,sunglasses,scarf,bagupper_garment,lower_garment,dress,belt,skirtleft_hand,right_hand,left_leg,right_leg,left_shoe,right_shoebackground
The mechanism is dead simple: for each selected class it does an exact color match against the ATR palette (cv2.inRange on the specific RGB value - [192,128,0] for head, [64,128,128] for left hand, and so on), ORs the results together, and stacks one mask per input image. The defaults are worth noticing: left_hand and right_hand default to True while everything else defaults to False - this pack is aimed at garment try-on, and hands are the usual thing you want to protect from being painted over.
Exact color matching has a real consequence: it only works on this pack's own ATR output. Any JPEG-ish compression artifacts or a different segmenter's palette will produce empty masks. Keep the parse and the mask extraction in one lineage.
Where it fits
This is the masking side of the VTON pipeline: parse → extract masks → use them for inpainting (keeping the garment out of the model's hands), background removal, or composing. If you want actual crops rather than masks, use tri3d-extract-parts-batch instead - it does the same class selection but cuts out the image region around each selected part. This node outputs pure MASK, ready for any mask-typed input: inpaint conditioning, denoise masks, composite, whatever.
Installing
ComfyUI Manager (search "tri3d"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/TRI3D-LC/tri3d-comfyui-nodes
Restart and install requirements (pip install -r custom_nodes/tri3d-comfyui-nodes/requirements.txt). No model downloads here - it's pure color-keying.
Troubleshooting
- Empty mask despite ticking a class - the segmentation colors don't match the palette (different segmenter, re-encoded image, or the parse node failed silently). Re-run the ATR parse and don't convert the maps between steps.
- Mask includes more than you wanted - remember the classes are OR'd together; untick the ones you don't want. The two hand classes default to on, which surprises people who just want the garment.
- Shape mismatch downstream - the node pads masks to the max width/height in the batch, so a mixed-size batch produces uniform shapes (that's on purpose, but it can shift positions if you mix resolutions).
It's a menu, not a brain - but for garment workflows, a menu that outputs exactly the masks you asked for is worth its weight in reruns.
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| batch_segs | IMAGE | — | |
| 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 |
|---|---|---|
| MASK | MASK | — |